Parameter style GENERAL

With the GENERAL parameter style, the parameters are passed to an external service program just as they are specified in the CREATE FUNCTION statement. This parameter style can be used only with scalar user-defined functions (UDFs).

The format is:

Read syntax diagramSkip visual syntax diagramSQL-result = func( SQL-argument )
SQL-argument
This argument is set by DB2® before calling the UDF. This value repeats n times, where n is the number of arguments specified in the function reference. The value of each of these arguments is taken from the expression specified in the function invocation. It is expressed in the data type of the defined parameter in the CREATE FUNCTION statement. Note: These parameters are treated as input only; any changes to the parameter values made by the UDF are ignored by Db2.
SQL-result
This value is returned by the UDF. Db2 copies the value into database storage. In order to return the value correctly, the function code must be a value-returning function. The database copies only as much of the value as defined for the return value as specified on the CREATE FUNCTION statement. If the CAST FROM clause is used in the CREATE FUNCTION statement, Db2 assumes the UDF returns the value as defined in the CAST FROM clause, otherwise Db2 assumes the UDF returns the value as defined in the RETURNS clause.

Because of the requirement that the function code be a value-returning function, any function code used for parameter style GENERAL must be created into a service program.