SQL-J Language Reference
Page 13 of 121

CREATE METHOD ALIAS statement

CREATE METHOD ALIAS adds an alias for a static Java method, making it appear to be a native built-in function.

Method aliases are not defined within a particular schema.

Syntax

CREATE METHOD ALIAS MethodAlias
FOR { JavaClassName | ClassAlias }. JavaMethodName

The Java class must be a public class and available on the current system or database class path. The method must exist and be public. A method alias and a class alias can share the same name.

CREATE METHOD ALIAS Examples

CREATE METHOD ALIAS ABS
FOR java.lang.Math.abs

CREATE METHOD ALIAS findCity
FOR JBMSTours.serializabletypes.City.findCity

-- City is an alias for JBMSTours.serializabletypes.City
CREATE METHOD ALIAS findCity
FOR City.findCity

-- a method alias and class alias can have
-- the same name
CREATE METHOD ALIAS City
FOR City.findCity

Once a method alias has been defined within a database, you refer to it with the alias alone:

VALUES ABS(-5)

VALUES findCity(getCurrentConnection(), 35)