Steps to creating and using a user-defined function
A user-defined function is similar to a host language subprogram or function. However, a
user-defined function is often the better choice for an SQL application because you can invoke it in
an SQL statement.
This section contains information that applies to all user-defined functions and specific
information about user-defined functions in languages other than Java™.
Creating and using a user-defined function involves these steps:
Setting up the environment for user-defined functions
A systems administrator probably
performs this step. The user-defined function environment is shown in the following figure.Figure 1. The user-defined function environment
It contains an application address space, from which a program invokes a user-defined
function; a Db2 system, where the packages
from the user-defined function are run; and a WLM-established address space, where the user-defined
function is executed. The steps for setting up and maintaining the user-defined function environment
are the same as for setting up and maintaining the environment for stored procedures in
WLM-established address spaces.
Writing and preparing the user-defined function
This step
is necessary only for an external user-defined function.
The
person who performs this step is called the user-defined function implementer.
Defining the user-defined function to Db2
The person who performs this step is
called the user-defined function definer.
Invoking the user-defined function from an SQL application
The
person who performs this step is called the user-defined function invoker.