Parameter style JAVA Java functions and methods
The recommended parameter style for Java™ functions and methods is PARAMETER STYLE JAVA.
The signature of PARAMETER STYLE JAVA functions and methods follows
this format:
public static return-type method-name ( SQL-arguments ) throws SQLException
-
return-type
- The data type of the value to be returned by the scalar routine. Inside the routine, the return value is passed back to the invoker through a return statement. method-name
- Name of the method. During routine registration, this value is specified with the class name in the EXTERNAL NAME clause of the routine's CREATE statement. SQL-arguments
- Corresponds to the list of input parameters in the routine's CREATE statement.
The following is an example of a Java function
that returns the product of its two input arguments:
public static double product( double in1, double in2 ) throws SQLException
{
return in1 * in2;
}
The corresponding CREATE FUNCTION statement for this scalar function
is as follows:
CREATE FUNCTION product( in1 DOUBLE, in2 DOUBLE )
RETURNS DOUBLE
LANGUAGE java
PARAMETER STYLE java
NO SQL
FENCED THREADSAFE
DETERMINISTIC
RETURNS NULL ON NULL INPUT
NO EXTERNAL ACTION
EXTERNAL NAME 'myjar:udfclass.product'
The preceding
statement assumes that the method is in a class called udfclass
that
is located in a JAR file that has been installed to the database server
with the Jar ID myjar
. JAR files can be installed
to a database server using the INSTALL_JAR
built-in
procedure.