ALLBASE/SQL Reference Manual (36216-90216)

Chapter 10 387
SQL Statements A - D
DESCRIBE
statement for input:
DESCRIBE INPUT Dynamic1 USING SQL DESCRIPTOR SqldaIn
If dynamic input parameters are present, the appropriate data buffer or host variables
must be loaded with the values of any dynamic parameters. Then if the statement is not
a query, it can be executed, as in this example using a data buffer:
EXECUTE Dynamic1 USING SQL DESCRIPTOR SqldaIn
If Dynamic1 is a SELECT statement and the language you are using supports
dynamically defined SELECT statements, use a cursor to manipulate the rows in the
query result:
DECLARE Dynamic1Cursor CURSOR FOR Dynamic1
Place the appropriate values into the SQL descriptor areas. Use the USING
DESCRIPTOR clause of the OPEN statement to identify where dynamic input
parameter information is located. Load related dynamic parameter data into the input
data buffer.
OPEN Dynamic1Cursor USING SQL DESCRIPTOR SqldaIn
Use the USING DESCRIPTOR clause of the FETCH statement to identify where to place
the rows selected.
FETCH Dynamic1Cursor USING DESCRIPTOR SqldaOut
.
.
.
When all rows have been processed, close the cursor:
CLOSE Dynamic1Cursor
3. Prepared statement is EXECUTE PROCEDURE
If the described statement is an EXECUTE PROCEDURE statement for a procedure with
multiple row result sets, the sqlmproc field of the sqlda data structure contains the
number of multiple row result sets (0 if there are none) following execution of the
DESCRIBE statement with default OUTPUT option. For example, if the statement you
described looks like the following, and the procedure was created with two multiple row
result SELECT statements and a WITH RESULT clause:
DynamicCmd = "EXECUTE PROCEDURE ? = proc(?, ? OUTPUT)"
PREPARE cmd FROM :DynamicCmd
Assuming you don't know the format of this prepared statement:
DESCRIBE OUTPUT cmd INTO sqldaout
The sqld of sqlda is set to 0, sqlmproc to 2, and sqloparm to 2.
DESCRIBE INPUT cmd USING sqldain