WLM ENVIRONMENT WLMIJAV
DYNAMIC RESULT SETS 1
PROGRAM TYPE SUB
PARAMETER STYLE JAVA;
Example: Defining a Java user-defined function: Suppose that you have written and
prepared a user-defined function that has these characteristics:
Fully-qualified function name MYSCHEMA.S2SAL
Input parameter INTEGER
Data type of returned value VARCHAR(20)
Language Java
Collection ID for the function package DSNJDBC
Package, class, and method name s2.S2Sal.getSals
Java data type of the method input
parameter
java.lang.Integer
JAR file that contains the function class sal_JAR
Type of SQL statements in the program Statements that modify DB2 tables
Function is called when input parameter is
null?
Yes
WLM environment name WLMIJAV
This CREATE FUNCTION statement defines the user-defined function to DB2:
CREATE FUNCTION MYSCHEMA.S2SAL(INTEGER)
RETURNS VARCHAR(20)
FENCED
MODIFIES SQL DATA
COLLID DSNJDBC
LANGUAGE JAVA
EXTERNAL NAME 'sal_JAR:s2.S2Sal.getSals(java.lang.Integer)'
WLM ENVIRONMENT WLMIJAV
CALLED ON NULL INPUT
PROGRAM TYPE SUB
PARAMETER STYLE JAVA;
In this function definition, you need to specify a method signature in the
EXTERNAL NAME clause because the data type of the method input parameter is
different from the default Java data type for an SQL type of INTEGER.
Related concepts
“Definition of a JAR file for a Java routine to DB2”
Related reference
″ALTER FUNCTION″ (DB2 SQL Reference)
″ALTER PROCEDURE″ (DB2 SQL Reference)
″CREATE FUNCTION″ (DB2 SQL Reference)
″CREATE PROCEDURE″ (DB2 SQL Reference)
Definition of a JAR file for a Java routine to DB2
One way to organize the classes for a Java routine is to collect those classes into a
JAR file. If you do this, you need to install the JAR file into the DB2 catalog.
DB2 provides built-in stored procedures that perform the following functions for
the JAR file:
SQLJ.INSTALL_JAR
Installs a JAR file into the local DB2 catalog.
168 Application Programming Guide and Reference for Java
™