Because an external user-defined function
is written in a programming language, preparing it is similar to the
way that you prepare any other application program.
Procedure
To prepare an external user-defined function for execution:
- Precompile the user-defined function program and bind the
DBRM into a package. You need to do this only if your user-defined
function contains SQL statements. You do not need to bind a plan for
the user-defined function.
- Compile the user-defined function program and link-edit
it with Language
Environment® and RRSAF.
You must compile the program
with a compiler that supports Language Environment and link-edit
the appropriate Language
Environment components with the user-defined function. You must
also link-edit the user-defined function with RRSAF.
The
program preparation JCL samples DSNHASM, DSNHC, DSNHCPP, DSNHICOB,
and DSNHPLI show you how to precompile, compile, and link-edit assembler,
C, C++, COBOL, and PL/I DB2® programs.
For object-oriented programs in C++, see JCL sample DSNHCPP2 for program
preparation hints.
- For a user-defined function that contains SQL statements,
grant EXECUTE authority on the user-defined function package to the
function definer.