FirebirdSQL logo

Function Body

The header section is followed by the function body, consisting of one or more PSQL statements enclosed between the outer keywords BEGIN and END.Multiple BEGIN …​ END blocks of terminated statements may be embedded inside the procedure body.

External UDR Functions

A stored function can also be located in an external module.In this case, instead of a function body, the CREATE FUNCTION specifies the location of the function in the external module using the EXTERNAL clause.The optional NAME clause specifies the name of the external module, the name of the function inside the module, and — optionally — user-defined information.The required ENGINE clause specifies the name of the UDR engine that handles communication between Firebird and the external module.The optional AS clause accepts a string literal “body”, which can be used by the engine or module for various purposes.

Warning

External UDR (User Defined Routine) functions created using CREATE FUNCTION …​ EXTERNAL …​ should not be confused with legacy UDFs (User Defined Functions) declared using DECLARE EXTERNAL FUNCTION.

UDFs are deprecated, and a legacy from previous Firebird functions.Their capabilities are significantly inferior to the capabilities to the new type of external UDR functions.