- database_name_1
- user_name_1
- An optional database or user name specified if the function is to be created or replaced in a non-default database or user.
- function_name
- The calling name for the function.
parameter_specification
Optional parameter names and locators for the variables to be passed to the function. A function that is used to compress or decompress a UDT column can have only one input parameter. The data type of the parameter can be any of the supported UDT data types.
You must specify opening and closing parentheses even if no parameters are to be passed to the function.
The maximum number of parameters a UDF accepts is 128.
The parameter data type of an algorithmic compression function used to compress a UDT column must match the RETURNS data type of its decompression function exactly. The type of an algorithmic compression function must also match the data type of the UDT column being compressed.
UDFs with a parameter type of UDT must reside in SYSUDTLIB rather than in SYSLIB.
- parameter name
- Parameter names must be unique within a UDF definition. If you specify one parameter name, you must specify names for all the parameters passed to the function. You cannot use SELF to name UDF parameters. If you do not specify parameter names, Vantage assigns unique names to them in the form P1, P2, …, P n. These names appear in the COMMENT statement, HELP FUNCTION output, and error messages. See COMMENT (Comment-Placing Form) and HELP FUNCTION.
- data_type
- A parenthetical comma-separated list of data types, including UDTs. The data types are required to differentiate between overloaded functions with the same name.
return_data_type
The data type for the value returned by the external function.
This clause is required for all UDFs.
You can specify the system-defined parameter type TD_ANYTYPE as the data type for a RETURNS clause. TD_ANYTYPE can assume any system-defined data type. Its attributes are determined when the function runs.
The RETURNS data type of an algorithmic function used to compress a UDT column must be VARBYTE(n).
The RETURNS data type of an algorithmic function used to decompress a UDT column must match the UDT parameter data type of its compression function and the data type of the UDT column exactly.
The return length n of the RETURNS VARBYTE(n) data type of an algorithmic decompression function must match the length of the compression function VARBYTE(n) parameter exactly.
You cannot specify a character server data set of KANJI1. Otherwise, Vantage returns an error to the requestor.
The function is responsible for providing the returned data with the correct type. If the return type is difficult for the function to create, specify a CAST FROM clause so the system can perform the appropriate data type conversion. For more information about CAST, see CAST in Explicit Data Type Conversions.
The result type has a dictionary entry in DBC.TVFields under the name RETURN0[n], where n is a sequence of digits appended to RETURN0 rows to make each value unique, ensuring no duplicate user-defined parameter names. The value of n is incremented until it no longer duplicates a parameter name.
- If the policy implements INSERT or UPDATE actions, the data type must be the same as that specified by the constraint definition. See CREATE CONSTRAINT.
The value for the parameter is whatever was inserted as a new row or was updated in an existing row.
- If the policy implements DELETE or SELECT actions, the data
type for the return parameter must be CHARACTER(1).
The value for the parameter is either T or F.
Do not specify the subscript indicated by n if there is no parameter name of RETURN0.
CAST FROM return_data_type
The result type returned by the external function that is to be converted to the type specified by the RETURNS clause.
Example:
...RETURNS DECIMAL(9,5) CAST FROM FLOAT...
Whenever a LOB that requires data type conversion is passed to an external UDF, the LOB must first be materialized for the conversion to take place.
The value for data_type can be a UDT.
You cannot specify a character server data set attribute of KANJI1. Otherwise, Vantage returns an error to the requestor.
language_clause
A code that represents the programming language in which the external function is written.
- LANGUAGE
- Keyword to introduce the programming language.
- C
- The external UDF is written in C.
- CPP
- The external UDF is written in C++.
- JAVA
- The external UDF is written in Java.
SQL_data_access
Specifies whether the external function body accesses the database or contains SQL statements.
Required for an external UDF. Must specify NO SQL.
function_attribute
Specific name for the function. Required for overloaded function names, otherwise optional and can only be specified once per function definition.
- database_name_2
- An optional database name.
- specific_function_name
- If you use specific_function_name to identify the C or C++ function name, take care to follow the identifier naming conventions of the C or C++ languages. The same suggestion applies to the naming conventions of the Java language for Java functions.
- CLASS
- Class of the function being defined.
- AGGREGATE
- AG
- The function class is aggregate.
- interim_size
- The size of the aggregate cache allocated for an aggregate UDF.
- PARAMETER STYLE
- Parameter passing convention to be used when passing parameters to the function.
- SQL
- Uses indicator variables to pass arguments.
- TD_GENERAL
- Uses parameters to pass arguments.
- JAVA
- Required for all Java functions.
- DETERMINISTIC
- Specifies that the function returns identical results for identical inputs.
- NOT DETERMINISTIC
- Specifies that the function does not always return identical results for identical inputs.
- CALLED ON NULL INPUT
- The function is evaluated whether parameters are null at the time the function is to be called or not.
- RETURNS NULL ON NULL INPUT
- If any parameters are null at the time the function is to be called, a null result is returned without evaluating the function.
code_specification
Single character code. Depending on the initial code in the sequence, the string specifies either the external function object name for the UDF or an encoded name or path for the components needed to create the external function.
- F
- Function object. The string that follows is the entry point
name of the C or C++ external function
object.
F!function_entry_point_name
- D
- Enables symbolic debugging for the UDF, which shows source code and displays variables by name. Without this option, UDFs can only be debugged at the machine instruction level. Specify this option for debugging purposes when UDFs are being tested. This option adds -g to the C compiler command line.
- S
- Server. The source or object code for the external function is stored on the server.
- C
- Client. The source or object code for the external function is stored on the client.
JAR_ID_specification
The following variables apply to Java functions only.
- JAR_ID
- The registered name of the JAR file associated with this function.
- java_class_name
- The name of the Java class contained within the JAR that contains the Java method to be run.
- method_name
- The name of the method that runs when the UDF runs.
- primitive
- A primitive parameter class as one of the following:
- BYTE
- DOUBLE
- INT
- LONG
- SHORT
- object
- An object parameter class definition in the format:
path_specification
Following is a list of the path specifications for the external function. You can repeat options as necessary with the exception of the package option. You can specify the following file types as external string literals.
- I
- Include file
(.h).
I!name_on_server!include_name
- L
- Library name for a nonstandard library files needed by the
UDF.
L!library_name
- O
- Object file.
O!name_on_server!object_name
- P
- Package name. You cannot use the package option with any
other options except F, the C function name
option.
P!package_name
- S
- Source
file.
S!name_on_server!source_name
- NS
- No source file. Source files and include files are not
stored in the function table. This option only affects how source code is
processed in the creation of a new function and applies to all source code
specified in the external string
literal.
NS!source_file!include_file
- delimiter
- Specify a delimiter character, such as !. You must use the same delimiter throughout the string specification.
- name_on_server
- Name the file on the server. Include files must have the same name specified in the include statement in the C source, without the extension.
- COMPRESS
- This UDF is to be used for algorithmic compression of data.
- DECOMPRESS
- Specifies that the UDF is to be used for decompression of data that was algorithmically compressed using the UDF named compress_UDF_name.
- GLOP_set_name
- Name of the GLOP set associated with this function. Can but need not exist when the function is created.
- EXTERNAL
- Introduction to the required external function body reference clause.
- external_function_name
- Entry point for the function object.
- EXTERNAL SECURITY
- Keywords introducing the external security clause.
- DEFINER
- The UDF runs in the client user context of the associated
security authorization object created for this purpose, which is contained
within the same database as the procedure.
- If you specify an authorization name, you must define an authorization object with that name before you can invoke the procedure.
- If you do not specify an authorization name, you must define a default DEFINER authorization object.
- authorization_name
- An optional identifier for this DEFINER.
- INVOKER
- The function runs using the INVOKER authorization associated with the logged on user who is running the function. See CREATE AUTHORIZATION and REPLACE AUTHORIZATION.