Determine return values dynamically
For an EXECUTE FUNCTION statement, the values in the INTO
clause identify where to store the return values of a user-defined
function. If the data types and number of the function return values
are not known at compile time, you cannot use host variables in the
INTO clause of EXECUTE FUNCTION to hold the values. Instead, your
program must perform the following tasks:
- Define a dynamic-management structure to serve as storage for
the definitions of the value or values that the user-defined function
returns.
You can use either a system-descriptor area or an sqlda structure to hold the return value or values.
Use of the system-descriptor area conforms to X/Open standards.
- Use the DESCRIBE statement to examine the prepared EXECUTE FUNCTION statement and describe the return value or values.
- Specify the dynamic-management structure as the location of the
data returned by the user-defined function.
From the dynamic-management structure, the program can move the return values into host variables.
Important: Use a dynamic-management structure only
if you do not know at compile time the number and data types of the
return values that the user-defined function returns. If you know
this information at compile time, see Execute user-defined routines in HCL OneDB for more information.
For information about how to use a system-descriptor area to hold function return values, see Handling unknown return values. To use an sqlda structure to hold return values, see Handling unknown return values.