With parameter style GENERAL, the parameters are passed into the
external service program just as they are specified in the CREATE FUNCTION
statement. This parameter style can only be used with scalar UDFs.
.------------------.
V |
>>-SQL-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.