ALLBASE/SQL Reference Manual (36216-90216)
386 Chapter10
SQL Statements A - D
DESCRIBE
• Detailed descriptions of how to use this statement are found in the "Using Dynamic
Operations" chapters of the ALLBASE/SQL C Application Programming Guide and
the ALLBASE/SQL Advanced Application Programming Guide, and in the "Using
Parameter Substitution in Dynamic Statements" chapter and the "Using Procedures in
Application Programs" chapter of the ALLBASE/SQL Advanced Application
Programming Guide.
Authorization
To describe a previously preprocessed SELECT statement, you must have authority that
would permit you to execute the SELECT statement. To describe a previously preprocessed
EXECUTE PROCEDURE statement, you must have authority that would permit you to execute
the procedure. You do not need authorization to describe other previously preprocessed
statements.
Examples
1. Prepared statement with known format
If you know in advance that the statement to be dynamically preprocessed is neither a
SELECT statement nor an EXECUTE PROCEDURE statement with results, and does not
contain dynamic parameters nor input/output host variables, you can prepare it and
execute it in one step, as follows:
EXECUTE IMMEDIATE :Dynam1
2. Prepared statement with unknown format
In other instances, it is more appropriate to prepare and execute the statement in
separate operations. For example, if you don't know the format of a statement, you
could do the following:
PREPARE Dynamic1 FROM :Dynam1
The statement stored in :Dynam1 is dynamically preprocessed.
DESCRIBE Dynamic1 INTO SqldaOut
If Dynamic1 is neither a SELECT statement (Sqld field of the Sqlda data structure is 0)
nor an EXECUTE PROCEDURE statement with results (sqlmproc = 0) and you know there
are no dynamic parameters in the prepared statement, use the EXECUTE statement to
execute the dynamically preprocessed statement.
If Dynamic1 is an EXECUTE PROCEDURE statement containing dynamic output
parameters, the sqloparm field of the Sqlda data structure contains the number of such
parameters in the statement. You can access the appropriate format array and data
buffer to obtain the data.
If it is possible that dynamic input parameters are present in the prepared statement or
that the statement is an EXECUTE PROCEDURE statement for a procedure with multiple
row result sets, you must further describe it. See the exproc function below which
emphasizes steps needed to process an EXECUTE PROCEDURE statement for a procedure
with multiple row result sets.
To check for dynamic input parameters in any type of DML statement, describe the