ALLBASE/SQL Reference Manual (36216-90216)

Chapter 10 385
SQL Statements A - D
DESCRIBE
Description
This statement cannot be used in ISQL, in COBOL and FORTRAN programs, or in
procedures.
•If
StatementName
refers to a SELECT statement, the DESCRIBE statement with the
(default) OUTPUT option sets the
sqld
field of the associated sqlda_type data
structure to the number of columns in the query result and sets the associated
sqlformat_type data structure to each column's name, length, and data type. On the
basis on this information, an application can parse a data buffer to obtain the column
values in the query result. The application reads the query result by associating the
StatementName
with a select cursor and using select cursor manipulation statements
(OPEN, FETCH, and CLOSE).
•If
StatementName
does not refer to a SELECT statement, the DESCRIBE statement
used with the OUTPUT option sets the
sqld
field of the associated sqlda_type data
structure to zero.
•If
StatementName
refers to a statement in which dynamic parameters have been
specified, the DESCRIBE statement with the INPUT option obtains the number of input
dynamic parameters (in the
sqld
field of the associated sqlda_type data structure) and
sets the associated sqlformat_type data structure to each column's name, length, and
data type. The application can use this information to load the appropriate data buffer
with dynamic parameter values.
•If
StatementName
refers to an EXECUTE PROCEDURE statement for a procedure with
multiple row result sets, the
sqlmproc
field of the associated sqlda_type data structure
is set to a non-zero value. The program reads the query results by associating the
StatementName
with a procedure cursor name and using procedure cursor
manipulation statements (OPEN, ADVANCE, FETCH, and CLOSE).
•If
StatementName
refers to an EXECUTE PROCEDURE statement containing output
dynamic parameters, the DESCRIBE statement with the (default) OUTPUT option
returns the number of output dynamic parameters in the
sqloparm
field of the
associated sqlda_type data structure.
•If
StatementName
refers to an EXECUTE PROCEDURE statement containing both input
and output dynamic parameters, you can issue the EXECUTE statement specifying the
USING INPUT AND OUTPUT option to execute the dynamically preprocessed
statement.
•If
StatementName
is an EXECUTE PROCEDURE statement containing single format
multiple row result set(s), the DESCRIBE statement with the RESULT option returns
the format information of the multiple row result set(s). If the procedure contains more
than one multiple row result set, all must return rows with compatible formats.
If the RESULT option is specified when describing an EXECUTE PROCEDURE statement
for a procedure created with no WITH RESULT clause, the sqld field of the related
SQLDA is set to zero, and no format information is written to the SQL descriptor area.
If the RESULT option is specified when describing a statement other than an EXECUTE
PROCEDURE statement, the DESCRIBE RESULT statement returns an error, and nothing
is written to the SQL descriptor area.