Declaring a UDF to a Database
Go Up to Working with UDFs and Blob Filters
Once a UDF has been written and compiled into a library, you must use the DECLARE EXTERNAL FUNCTION
statement to declare each function to each database where you want to use it. Each function in a library must be declared separately, but needs to be declared only once to each database.
Declaring a UDF to a database informs the database about its location and properties:
- The UDF name as it will be used in embedded SQL statements
- The number and data types of its arguments
- The return data type
- The name of the function as it exists in the UDF module or library
- The name of the library that contains the UDF
You can use isql
, IBConsole, or a script to declare your UDFs.
You can use the following syntax to execute a DECLARE EXTERNAL FUNCTION statement:
DECLARE EXTERNAL FUNCTION name [data_type ;
| CSTRING (int) | DESCRIPTOR [, data_type | CSTRING (int) ...] DESCRIPTOR]
RETURNS {data_type [BY VALUE] | CSTRING (int) | PARAMETER n}
[FREE_IT]
ENTRY_POINT 'entryname'
MODULE_NAME 'modulename';
The following describes the arguments you can append to a DECLARE EXTERNAL FUNCTION statement.
Argument | Description |
---|---|
<name> |
Name of the UDF to use in SQL statements; can be different from the name of the function specified after the |
<data_type> |
Data type of an input or return parameter
|
|
Specifies a UDF that returns a null-terminated string <int> bytes in length. |
DESCRIPTOR |
Ensures that the InterBase server passes all the information it has about a particular data type to the function via the Descriptor control structure. |
|
Specifies the return value of a function. |
|
Specifies that a return value should be passed by value rather than by reference. |
|
|
|
Frees memory of the return value after the UDF finishes running.
|
'<entryname>' |
Quoted string specifying the name of the UDF in the source code and as stored in the UDF library. |
'<modulename>' |
Quoted specification identifying the library that contains the UDF.
|