EXTERNAL NAME clause

The EXTERNAL NAME clause specifies the Java method to be called in a CREATE FUNCTION or CREATE PROCEDURE statement, and it specifies a Java class in a CREATE AGGREGATE or CREATE TYPE statement.

See CREATE FUNCTION statement, CREATE PROCEDURE statement, CREATE DERBY AGGREGATE statement, and CREATE TYPE statement for more information.

Syntax

EXTERNAL NAME singleQuotedString

The singleQuotedString cannot have any extraneous spaces.

The method name specified in the CREATE FUNCTION or CREATE PROCEDURE statement normally takes the following form:

'class_name.method_name[(parameterTypes)]'

The optional parameterTypes specification is needed when the Java signature determined from the SQL declaration is ambiguous.

If the class is a static nested class, or if the method is in a static nested class, use a dollar sign ($) as a separator between the outer and static class. For example, suppose you have the following class and method definition:

public class TestFuncs {
    public static final class MyMath {
        public static double pow( double base, double power ) {
            return Math.pow( base, power );
        }
    }
}

If you use CREATE FUNCTION to bind this pow method to a user-defined function, the external name should be TestFuncs$MyMath.pow, not TestFuncs.MyMath.pow.

Examples

-- Specify the Mode class as an external name
CREATE DERBY AGGREGATE mode FOR INT
EXTERNAL NAME 'com.example.myapp.aggs.Mode';
-- Specify the pow method in the static class MyMath
CREATE FUNCTION MYPOWER ( X DOUBLE, Y DOUBLE )
RETURNS DOUBLE
PARAMETER STYLE JAVA
NO SQL LANGUAGE JAVA
EXTERNAL NAME 'TestFuncs$MyMath.pow'
-- create a function to round a Double to a specified number of decimal places
CREATE FUNCTION DoubleFormat (value FLOAT, places INTEGER)
RETURNS FLOAT
PARAMETER STYLE JAVA
LANGUAGE JAVA
EXTERNAL NAME
'utils.Utils.Double(java.lang.Float,java.lang.Integer)'