Firebird Documentation IndexFirebird 2.1 Language Ref. UpdateDDL statements → EXTERNAL FUNCTION
Firebird Home Firebird Home Prev: EXCEPTIONFirebird Documentation IndexUp: DDL statementsNext: FILTER

EXTERNAL FUNCTION

DECLARE EXTERNAL FUNCTION
ALTER EXTERNAL FUNCTION

DECLARE EXTERNAL FUNCTION

Available in: DSQL, ESQL

Description: This statement makes an external function (UDF) available in the database.

Syntax: 

DECLARE EXTERNAL FUNCTION localname
   [<arg_type_decl> [, <arg_type_decl> ...]]
   RETURNS {<return_type_decl> | PARAMETER 1-based_pos} [FREE_IT]
   ENTRY_POINT 'function_name' MODULE_NAME 'library_name'

<arg_type_decl>     ::=  sqltype [BY DESCRIPTOR] | CSTRING(length)
<return_type_decl>  ::=  sqltype [BY {DESCRIPTOR|VALUE}] | CSTRING(length)

Restrictions

  • The BY DESCRIPTOR passing method is not supported in ESQL.

You may choose localname freely; this is the name by which the function will be known to your database. You may also vary the length argument of CSTRING parameters (more about CSTRINGs in the note near the end of the book).

BY DESCRIPTOR parameter passing

Available in: DSQL

Added in: 1.0

Description: Firebird introduces the possibility to pass parameters BY DESCRIPTOR; this mechanism facilitates the processing of NULLs in a meaningful way. Notice that this only works if the person who wrote the function has implemented it. Simply adding “BY DESCRIPTOR” to an existing declaration does not make it work – on the contrary! Always use the declaration block provided by the function designer.

RETURNS PARAMETER n

Available in: DSQL, ESQL

Added in: IB 6

Description: In order to return a BLOB, an extra input parameter must be declared and a “RETURNS PARAMETER n” clause added – n being the position of said parameter. This clause dates back to InterBase 6 beta, but somehow didn't make it into the Language Reference (it is documented in the Developer's Guide though).

ALTER EXTERNAL FUNCTION

Available in: DSQL

Added in: 2.0

Description: Alters an external function's module name and/or entry point. Existing dependencies are preserved.

Syntax: 

ALTER EXTERNAL FUNCTION funcname
   <modification> [<modification>]

<modification>  ::=  ENTRY_POINT 'new-entry-point'
                     | MODULE_NAME 'new-module-name'

Example: 

alter external function Phi module_name 'NewUdfLib'
Prev: EXCEPTIONFirebird Documentation IndexUp: DDL statementsNext: FILTER
Firebird Documentation IndexFirebird 2.1 Language Ref. UpdateDDL statements → EXTERNAL FUNCTION