User-defined routines
You can create routines to encapsulate logic of your own or use the database provide routines that capture the functionality of most commonly used arithmetic, string, and casting functions. The user-defined routines refer to any procedures, functions, and methods that are created by the user.
You can create your own procedures, functions and methods in any of the supported implementation styles for the routine type. Generally the prefix 'user-defined' is not used when referring to procedures and methods. User-defined functions are also commonly called UDFs.
User-defined routine creation
- CREATE PROCEDURE
- CREATE FUNCTION
- CREATE METHOD
User-defined routine definitions are stored in the SYSTOOLS system catalog table schema.
User-defined routine logic implementation
- Sourced: user-defined routines can be sourced from the logic of existing built-in routines.
- SQL: user-defined routines can be implemented using only SQL statements.
- External: user-defined routines can be implemented using one of
a set of supported programming languages.
When routines are created in a non-SQL programming language, the library or class built from the code is associated with the routine definition by the value specified in the EXTERNAL NAME clause. When the routine is invoked the library or class associated with the routine is run.
User-defined routines can include a variety of SQL statements, but not all SQL statements.
User-defined routines are strongly typed, but type handling and error-handling mechanisms must be developed or enhanced by routine developers.
After a database upgrade, it may be necessary to verify or update routine implementations.
In general, user-defined routines perform well, but not as well as built-in routines.
User-defined routines can invoke built-in routines and other user-defined routines implemented in any of the supported formats. This flexibility allows users to essentially have the freedom to build a complete library of routine modules that can be re-used.
In general, user-defined routines provide a means for extending the SQL language and for modularizing logic that will be re-used by multiple queries or database applications where built-in routines do not exist.