You can use an sqlda structure to save values that
a dynamically executed user-defined function returns.
About this task
For an introduction on how to handle unknown return values
from a user-defined function, see Determine return values dynamically.
To use an sqlda structure
to handle unknown-function return values:
Procedure
- Declare a variable to hold the address of an sqlda structure.
- Assemble and prepare an EXECUTE FUNCTION statement.
- Use the DESCRIBE...INTO statement to perform two tasks:
- Allocate an sqlda structure.
- Determine the number and data types of function return
values.
- After the DESCRIBE statement, you can test the SQLCODE
variable (sqlca.sqlcode) for the defined constant SQ_EXECPROC
to check for a prepared EXECUTE FUNCTION statement.
- Examine the sqltype and sqllen fields of sqlda for
each return value to determine the amount of memory that is required
to allocate for the data.
- Execute the EXECUTE FUNCTION statement and store the return
values in the sqlda structure.
The statement
you use to execute a user-defined function depends on whether the
function is a noncursor function or a cursor function.
- Deallocate any memory you allocated to the sqlda structure.