Creating DB2 user-defined functions using a wizard
You can use the New UDF wizard to create DB2 user-defined functions (UDFs) in SQL.
Prerequisites: Before you can create a DB2 user-defined function, complete the following prerequisite steps:
- Create or import a DB2 database definition in your Data Definition view. The definition must include at least one schema and table. You can either create a database definition in the Data Definition view, or you can connect to a database using the New Database Connection wizard in the Database Explorer view and copy the definitions to a folder in the Data Definition view.
- Enable workbench capabilities for database development. To enable these capabilities:
- Click Window > Preferences from the main menu.
- Click Workbench > Capabilities, and select the Database Developer check box to enable all database capabilities.
To create a user-defined function using the wizard:
- Switch to the Data perspective.
- In the Data Definition view, right-click the User-Defined Functions folder, and click New > SQL User-defined Function. The New User-Defined Function (UDF) wizard opens.
- Complete the steps of the wizard.
- Click Finish.
The user-defined function is created and added to your database definition.
Note: The New User-Defined Function (UDF) wizard does not support all data types on all DB2 UDB servers. When creating a table UDF, the wizard recommends SQL data types for the data returned for each column. If the wizard is unable to map a corresponding data type for a column because that data type is not supported, the Data type column on the Results page of the DB Output view will show "not mapped". To fix this, open the generated user-defined function in the editor and change the data type manually.
By default, creating the user-defined function does not register the user-defined function on the database. To build the user-defined function on the database, see Building DB2 routines.
Parent topic
DB2 user-defined functions (UDFs)
Related concepts
Developing DB2 user-defined functions
Using DB2 user-defined functions in applications
Related tasks
Creating DB2 user-defined functions for WebSphere MQ
Copying DB2 database definitions to a local project
Creating a DB2 user-defined function to access Web services
Related reference
User-defined function catalog by DB2 Universal Database server
User-defined function support by type
Stored procedure and user-defined function support by DB2 Universal Database server type