The CREATE FUNCTION statement allows you to create Java functions, which you can then use in an expression.
CREATE FUNCTION function-name ( [ FunctionParameter [, FunctionParameter] ] * ) RETURNS DataType [ FunctionElement ] *
[ schemaName. ] SQL92Identifier
If schema-Name is not provided, the current schema is the default schema. If a qualified procedure name is specified, the schema name cannot begin with SYS.
PararameterName must be unique within a function.
The syntax of DataType is described in Data types.
{ | LANGUAGE { JAVA } | EXTERNAL NAME string | PARAMETER STYLE JAVA | { NO SQL | CONTAINS SQL | READS SQL DATA } | { RETURNS NULL ON NULL INPUT | CALLED ON NULL INPUT } }
JAVA- the database manager will call the function as a public static method in a Java class.
class_name.method_nameThe External Name cannot have any extraneous spaces.
JAVA - The function will use a parameter-passing convention that conforms to the Java language and SQL Routines specification. INOUT and OUT parameters will be passed as single entry arrays to facilitate returning values. Result sets are returned through additional parameters to the Java method of type java.sql.ResultSet[] that are passed single entry arrays.
Derby does not support long column types (for example Long Varchar, BLOB, and so on). An error will occur if you try to use one of these long column types.
Indicates whether the function issues any SQL statements and, if so, what type.
CREATE FUNCTION TO_DEGREES(RADIANS DOUBLE) RETURNS DOUBLE PARAMETER STYLE JAVA NO SQL LANGUAGE JAVA EXTERNAL NAME 'java.lang.Math.toDegrees'