PREPARE INTO: Information about a prepared statement can also be obtained by using the INTO clause of the PREPARE statement.
Allocating the SQL descriptor: Before the DESCRIBE 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 result columns, a warning (SQLSTATE 01005) is returned.
Allocating the SQLDA: In C, COBOL, PL/I, and RPG, before the DESCRIBE or PREPARE INTO statement is executed, enough storage must be allocated for some number of SQLVAR occurrences. SQLN must then be set to the number of SQLVAR occurrences that were allocated. To obtain the description of the columns of the result table of a prepared SELECT statement, the number of occurrences of SQLVAR entries must not be less than the number of columns. Furthermore, if the columns include LOBs or distinct types, the number of occurrences of SQLVAR entries should be two times the number of columns. See Determining how many SQLVAR occurrences are needed for more information.Among the possible ways to allocate the SQLDA are the three described below:
This technique uses a large amount of storage that is never deallocated, even when most of this storage is not used for a particular select list.
This technique allows better storage management than the first technique, but it doubles the number of DESCRIBE statements.
This technique is a compromise between the first two techniques. Its effectiveness depends on a good choice of size for the original SQLDA.
(C) Copyright IBM Corporation 1992, 2006. All Rights Reserved.