List:General Discussion« Previous MessageNext Message »
From:Vikram Vaswani Date:December 25 2008 10:46am
Subject:Question on default database for stored functions
View as plain text  

According to the MySQL manual, "By default, a routine is associated with 
the default database.When the routine is invoked, an implicit USE 
db_name is performed (and undone when the routine terminates)"

However, when I tried accessing a stored routine from another database, 
I received an error. Output below:

mysql> USE test
mysql> DELIMITER //
mysql> CREATE FUNCTION get_area(radius INT)
     ->   BEGIN
     ->     RETURN PI() * radius * radius;
     ->   END
     -> //
Query OK, 0 rows affected (0.13 sec)
mysql> DELIMITER ;
mysql> USE test2
Database changed
mysql> select get_area(11);
ERROR 1305 (42000): FUNCTION test2.get_area does not exist

Can someone tell me what I'm doing wrong? Thanks.

Question on default database for stored functionsVikram Vaswani25 Dec
  • RE: Question on default database for stored functionsJerry Schwartz26 Dec
    • Re: Question on default database for stored functionsPeter Brawley26 Dec