Databases Reference
In-Depth Information
FROM country
WHERE code = param_country_code
INTO var_country_name;
RETURN var_country_name;
END
//
We should note that our newly-created function can be seen on the database's
Structure page, along with its friend, the add_page procedure:
Testing the function
To test the function we just created, enter the following query in a query box (refer to
Chapter 11 ):
SELECT CONCAT('ca->', get_country_name('ca'), ', zz->',
get_country_name('zz')) as test;
This will produce the following result:
ca->Canada, zz->not found
Exporting stored procedures and functions
When exporting a database, procedures and functions appear in an SQL export.
This is because the Add CREATE PROCEDURE / FUNCTION / EVENT checkbox
is selected by default in the Object creation options dialog of the Export page (it
can be seen in the Custom export mode). Here is the part of the export file related to
procedures and functions:
DELIMITER $$
--
-- Procedures
--
CREATE DEFINER=`marc`@`%` PROCEDURE `add_page`(IN param_isbn
 
Search WWH ::




Custom Search