User-defined functions

User-defined functions are functions that are created using the CREATE FUNCTION statement and registered to the Db2 in the catalog. These functions allow users to extend the function of Db2 by adding their own or third party vendor function definitions.

A user-defined function is an SQL, external, or sourced function. An SQL function is defined to the database using only SQL statements. An external function is defined to the database with a reference to an external program that is executed when the function is invoked. A sourced function is defined to the database with a reference to a built-in function or another user-defined function. Sourced functions can be used to override built-in aggregate and scalar functions for use on distinct types.

A user-defined function resides in the schema in which it was registered. The schema cannot be SYSIBM.

To help you define and implement user-defined functions, sample user-defined functions are supplied with Db2. You can also use these sample user-defined functions in your application program just as you would any other user-defined function if the appropriate installation job has been run.