A stored function (also called a user function or user-defined function) is a set of PL/SQL statements you can call by name. Stored functions are very similar to procedures, except that a function returns a value to the environment in which it is called. User functions can be used as part of a SQL expression.
To create a new function:
- select the Database | New Object... main menu item;
- select Function in the Create New Object dialog;
- define function properties using the appropriate tabs of Function Editor.
To create a new function with the same properties as one of existing functions has:
- select the Database | Duplicate Object... main menu item;
- follow the instructions of Duplicate Object Wizard.
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.
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 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;
Shift+Del to drop the object from the database.