
The DESCRIBE CURSOR statement gets information about a cursor. The information, such as column information, is put into a descriptor.
This statement can only be embedded in an application program, SQL function, SQL procedure, or trigger. It is an executable statement that cannot be dynamically prepared. It must not be specified in Java™ or REXX.
None required.
>>-DESCRIBE CURSOR--+-cursor-name-+-----------------------------> '-variable----' .-SQL-. .-LOCAL--. >--+-USING--+-----+--DESCRIPTOR--+--------+--SQL-descriptor-name-+->< | '-GLOBAL-' | '-INTO----descriptor-name-------------------------------------'
If a variable is specified:
See GET DESCRIPTOR for
an explanation of the information that is placed in the SQL descriptor.
When the DESCRIBE statement is executed, the database manager assigns values to the variables of the SQLDA as follows:
If the value of SQLD is n, where n is greater than 0 but less than or equal to the value of SQLN, values are assigned to the first n occurrences of SQLVAR so that the first occurrence of SQLVAR contains a description of the first column of the result table, the second occurrence of SQLVAR contains a description of the second column of the result table, and so on. For information about the values assigned to SQLVAR occurrences, see Field descriptions in an occurrence of SQLVAR.
Allocating the SQL descriptor: Before the DESCRIBE CURSOR statement is executed, the SQL descriptor must be allocated using the ALLOCATE DESCRIPTOR statement. If the number of descriptor items allocated is less than the number of columns in the cursor result set, a warning (SQLSTATE 01005) is returned.
Allocating the SQLDA: Before the DESCRIBE CURSOR statement is executed, the value of SQLN must be set to a value greater than or equal to zero to indicate how many occurrences of SQLVAR are provided in the SQLDA and enough storage must be allocated to contain SQLN occurrences. To obtain the description of the columns of the cursor result set, the number of occurrences of SQLVAR must not be less than the number of columns.
For a description of techniques that can be used to allocate the SQLDA, see SQLDA (SQL descriptor area).
Place information about the result set associated with cursor C1 into an SQL descriptor.
EXEC SQL ALLOCATE DESCRIPTOR 'DESCR1'; EXEC SQL DESCRIBE CURSOR C1 USING SQL DESCRIPTOR 'DESCR1';
