CREATE FUNCTION Statement (Java UDF)

Creates a new external Java table UDF function in the database.

Syntax

CREATE [ OR REPLACE | TEMPORARY ] FUNCTIONowner.]function-name  
   ( [ parameter, … ] )
   [ SQL SECURITYINVOKER | DEFINER } ]
   RETURNS data-type
   ON EXCEPTION RESUME
   | [ NOT ] DETERMINISTICcompound-statementAS tsql-compound-statement
   | EXTERNAL NAME 'java-call' LANGUAGE JAVA [ ALLOW | DISALLOW SERVER SIDE REQUESTS ] environment-name}

parameter:
   IN parameter-name data-type DEFAULT expression ]

tsql-compound-statement: 
   sql-statement 
    sql-statement

java-call:
   '[ package-name.]class-name.method-name method-signature'

method-signature:
   ( [ field-descriptor, ….] ) return-descriptor

field-descriptor and return-descriptor:
   Z | B | S | I | J | F | D | C | V | descriptor | L class-name;

Parameters

Examples

Usage

When functions are executed, not all parameters need to be specified. If a default value is provided in the CREATE FUNCTION statement, missing parameters are assigned the default values. If an argument is not provided by the caller and no default is set, an error is given.

Standards

  • SQL—ISO/ANSI SQL compliant.

  • Sybase—Not supported by Adaptive Server Enterprise.

Permissions

For function to be owned by self – Requires the CREATE PROCEDURE system privilege

For function to be owned by any user – Requires one of:
  • CREATE ANY PROCEDURES system privilege.
  • CREATE ANY OBJECT system privilege.
To create a function containing an external reference, regardless of whether or not they are the owner of the function, also requires the CREATE EXTERNAL REFERENCE system privilege.