Mimer SQL Reference Manual TOC PREV NEXT INDEX

Mimer Developer Site

www.mimer.com/developer


CREATE FUNCTION


Creates a new stored user-defined function.

where function-definition is:

Usage

Embedded/Interactive/ODBC/JDBC.

Description

The function-name should follow the normal rules for naming database objects, see Naming Objects.

If function-name is specified in its unqualified form, the function will be created in the schema which has the same name as the current ident.

If function-name is specified in its fully qualified form (i.e. schema-name.function-name) the function will be created in the named schema (in this case, the current ident must be the creator of the specified schema).

The fully qualified function name must be used by all idents except the ident that has the same name as the schema to which the function belongs.

The parameter-name should follow the normal rules for naming SQL identifiers, see SQL Identifiers.

The permitted values for data-type are described in Data Types in SQL Statements.

If neither DETERMINISTIC nor NOT DETERMINISTIC is specified, then NOT DETERMINISTIC is implicit.

If DETERMINISTIC is specified, then the function is guaranteed to produce the same result every time it is invoked with the same set of input values and repeated invocations of it can, therefore, be optimized.

Access Options

The following access options may be specified:

If neither CONTAINS SQL, READS SQL DATA nor MODIFIES SQL DATA is specified, then CONTAINS SQL is implicit.

Restrictions

A function created this way cannot be added to a module.

Two functions with the same name cannot belong to the same schema.

It is not possible to create a synonym for a function name.

A parameter name must be unique within the function.

The parameter mode cannot be specified for a function parameter (as it is for a procedure parameter).

The ROW data type cannot be specified in data-type.

If DETERMINISTIC is specified, the procedural SQL statement of the function may not contain, or be, a reference to: SESSION_USER, CURRENT_PROGRAM, CURRENT_DATE, LOCALTIME or LOCALTIMESTAMP and the function may not invoke functions or procedures that are not deterministic.

If an invoked function attempts to execute a COMMIT or ROLLBACK statement in a context where this is not permitted, (i.e. after being invoked from within a result set procedure, from within an atomic compound statement or from a data manipulation statement in one of these contexts) an exception will be raised.

An ident must have EXECUTE privilege on the function in order to invoke it.

Notes

A function is invoked by specifying its name and parameter list where a value-expression would be used.

All function parameters have the default mode (which is IN). See CREATE PROCEDURE for details on the parameter modes.

A parameter-name can be the same as the name of the function, but this is not recommended.

Refer to the Mimer SQL User's Manual for details on using the CREATE FUNCTION statement in BSQL, where the "@" delimiter is required.

Standard Compliance

Standard
Compliance
Comments
SQL/PSM
YES
Fully compliant.



Upright Database Technology AB
Voice: +46 18 780 92 00
Fax: +46 18 780 92 40
dbtechnology@upright.se
Mimer SQL Reference Manual TOC PREV NEXT INDEX