EMS logo

Products Navigation

SQL Manager for MySQL

Our Partnership Status

MySQL Gold Certified Partner
Microsoft Certified Partner
Oracle Certified Partner
Embarcadero Technology Partner

EMS SQL Manager for MySQL

On-line Documentation

Stored Functions


Stored functions are routines that are available in 5.x and later versions of MySQL server. A Stored function is a set of SQL commands that returns the result and can be stored in the server. Once this is done, clients do not need to keep re-issuing the individual commands but can refer to the stored function instead.

 

 

Creating Stored Functions

 

To create a new function:

Hint: To create a new function, you can also right-click the Functions node or any object within this node in the DB Explorer tree and select the New Function item from the context menu.

 

To create a new function with the same properties as one of existing functions has:

Alternatively, you can right-click a function in the DB Explorer tree and select the Duplicate Function <function_name>... context menu item.

 

Duplicate Object Wizard allows you to select the database to create a new function in, and to edit the result SQL statement for creating the function.

 

 

Editing Stored Functions

 

To edit an existing function:

  • select the function for editing in the DB Explorer tree (type the first letters of the function name for quick search);
  • right-click the object and select the Edit Function <function_name> context menu item, or simply double-click the function;
  • edit function definition using the appropriate tabs of Function Editor.

To change the name of a function:

  • select the function to rename in the DB Explorer tree;
  • right-click the function alias and select the Rename Function <function_name>... item from the context menu;
  • edit the function name using the Rename Object... dialog.

 

Dropping Stored Functions

 

To drop a function:

  • select the function to drop in the DB Explorer tree;
  • right-click the object and select the Drop Function <function_name>... context menu item;
  • confirm dropping in the dialog window.

 

Note: If more convenient, you can also use the following shortcuts:

Ctrl+N to create a new function;

Ctrl+O to edit the selected function;

Ctrl+R to rename the function;

Shift+Del to drop the object from the database.