EXTERNAL NAME clause

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

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'

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'