Functions

Similar to stored procedures, user-defined Functions are physically stored within a database in compiled form under a certain name. This allows you to share the functions between a number of programs. The distinct feature of functions is that they can return a value as a result of their work.

Functions are implemented in the 5.0 version of MySQL Server, and you can completely manage them with SQLyog.


Create Function

To create a new function, use the menu item Others -> Function -> Create Function.

Enter the function name in the appeared dialog, and SQLyog will generate a function template in a separate tab of the SQL Window. Fill the template as necessary for you. Note that the template contains the command to drop the function before its creation in case it already exists.

Use the toolbar buttons or hotkeys to execute the queries. As editor tabs of a special kind are used for functions creation/alteration, pressing both F5 and Shift+F5 keys leads to execution of all queries present in the SQL window.


Alter Function

To alter an existing function, select it in the Object browser and use the menu item Others -> Function -> Alter Function or press F6.

A template for the function alteration will appear in a separate tab of the SQL Window. The template is similar to that used for a function creation.

Use the toolbar buttons or hotkeys to execute the queries. As editor tabs of a special kind are used for functions creation/alteration, pressing both F5 and Shift+F5 keys leads to execution of all queries present in the SQL window.


Drop Function

To drop an existing function, select it in the Object browser and use the menu item Others -> Function -> Drop Function. Then confirm the operation in the appeared dialog.