Progress
Embedded SQL-92
Guide and Reference
DESCRIBE Statement
Use the DESCRIBE statement to obtain information about a prepared statement. This is an executable statement that can only be embedded in an ESQL program and cannot be dynamically prepared. The DESCRIBE statement can be used to describe INPUT host variables or OUTPUT host variables. This is the syntax for a DESCRIBE statement:
Execute the DESCRIBE BIND VARIABLES statement after preparing an SQL statement and before executing the OPEN statement for the cursor. Specify the input SQLDA in the OPEN cursor statement with the USING DESCRIPTOR clause.
This is the syntax for a USING DESCRIPTOR clause in an OPEN cursor statement:
EXAMPLE
The following DESCRIBE statement populates an SQLDA with information from a prepared SQL statement:
The sel_stmt is the output of a PREPARE operation on an SQL statement. When the DESCRIBE statement is executed, values are assigned to the variables in the SQLDA as follows:
- SQLD_NVARS contains the number of outputs returned. If the size of the sqlda passed is not enough to return information about all the result columns of the SELECT statement, SQLD_NVARS is negative. In this case, the absolute value of SQLD_NVARS gives the actual number of result columns of the SELECT statement. The application can use this to de-allocate the SQLDA, allocate a new SQLDA for the required size, and then execute the DESCRIBE statement again.
- SQLD_TYPES contains the data types of each column specified in the SELECT list.
- SQLD_LENGTHS contains the lengths of each column depending on the data type of the column.
Copyright © 2004 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |