Creating DB2 user-defined functions from the Database Explorer

You can use SQL Editor or the Routine Editor to create DB2® SQL user-defined functions.

Using the SQL Editor, you can create a user-defined function based on a template, and modify the template as needed. This method is useful if you want to quickly create a user-defined function and run it on the server.

Using the Routine Editor, you can specify the name and language for a user-defined function and then open the source code in the Routine editor for further modification. When you create a user-defined function using this method, you must specify a data development project to store the source code for the user-defined function. You can specify an existing project that is associated with the connection you are working in, or you can create a new project.

To create a user-defined function from the Database Explorer:

  1. Switch to the Data perspective.
  2. In the Database Explorer, right-click the User-Defined Functions folder under a database connection, and click one of the following menu items:
    • Click New > With SQL Editorto open a user-defined function template in the SQL Editor.
    • Click New > With Routine Editor to open a window so that you can specify a name, language, and data development project for the user-defined function, then click Finish.
    If you use the SQL Editor, you can modify the template and run the user-defined function from the SQL editor view to deploy the user-defined function to the database. If you use the Routine Editor, the user-defined function is added to the User-Defined Functions folder in the data development project that you specified, and the user-defined function opens in the routine editor.

Comentarios