SQL Maestro for MySQL online help
Functions
Stored routines (procedures and functions) are supported in MySQL 5.1. A stored procedure is a set of SQL statements that can be stored in the server. Once this has been done, clients don't need to keep reissuing the individual statements but can refer to the stored procedure instead. SQL Anywhere allows to define user-specific database functions. In an SQL statement, you can then use these user-defined database functions in the same way as any other predefined functions.
New Functions are created within Create Function Wizard. In order to run the wizard you should either
• | select the Object | Create Database Object... main menu item; |
• | select the Function icon in the Create Database Object dialog |
or
• | select the Functions list or any object from that list in the explorer tree; |
• | select the Create New Function... item from the popup menu |
or
• | open and the Functions tab there; |
• | press the Insert key or select the Create New Function item from the popup menu (alternatively, you may use the corresponding link of the Navigation Bar). |
To create a new Function with the same properties as one of the existing Functions has:
• | select the Object | Duplicate Database Object... main menu item; |
• | follow the instructions of Duplicate Object Wizard. |
|
Functions can be edited within FunctionEditor. In order to open the editor you should either
• | select the Function for editing in the explorer tree (type the first letters of the Function name for quick search); |
• | select the Edit Function item from the popup menu |
or
• | open and the Functions tab there; |
• | select the Function to edit; |
• | press the Enter key or select the Edit Function item from the popup menu (alternatively, you may use the corresponding link of the Navigation Bar). |
You can change the name of the Function using the Rename Function dialog:
• | select the Function to rename in the explorer tree; |
• | select the Rename Function item from the popup menu. |
|
To execute the Function:
• | select the Function in the explorer tree (type the first letters of the Function name for quick search); |
• | select the Edit Function... item from the popup menu; |
• | execute the Function using the Execute link of the Navigation Bar |
or
• | open Schema Editor and the Functions tab there; |
• | select the Function to execute; |
• | press the Enter key or select the Edit Function item from the popup menu, or use the corresponding link of the Navigation Bar; |
• | execute the Function using the Execute link of the Navigation bar. |
|
To drop a Function:
• | select the Function to drop in the explorer tree; |
• | select the Drop Function item from the popup menu |
or
• | open and the Functions tab there; |
• | select the Function to drop; |
• | press the Delete key or select the Drop Function item from the popup menu (alternatively, you may use the corresponding link of the Navigation Bar) |
and confirm dropping in the dialog window.
|