Use the information provided here as an example of how to allocate the minimum SQLDA structure for a statement.
You can only allocate a smaller SQLDA structure with programming languages, such as C and C++, that support the dynamic allocation of memory.
EXEC SQL
PREPARE STMT INTO :*minsqlda FROM :dstring;
Suppose that the statement contained in dstring is a SELECT statement that returns 20 columns in each row. After the PREPARE statement (or a DESCRIBE statement), the SQLD field of the SQLDA contains the number of columns of the result table for the prepared SELECT statement.
The SQLVAR entries in the SQLDA are set in the following cases:
The first SQLD SQLVAR entries are set and SQLDOUBLED is set to blank.
2* SQLD SQLVAR entries are set and SQLDOUBLED is set to 2.
The first SQLD SQLVAR entries are set and SQLDOUBLED is set to blank. If the SQLWARN bind option is YES, a warning SQLCODE +237 (SQLSTATE 01594) is issued.
The SQLVAR entries in the SQLDA are not set (requiring allocation of additional space and another DESCRIBE) in the following cases:
No SQLVAR entries are set and SQLDOUBLED is set to blank. If the SQLWARN bind option is YES, a warning SQLCODE +236 (SQLSTATE 01005) is issued.
Allocate SQLD SQLVAR entries for a successful DESCRIBE.
No SQLVAR entries are set and SQLDOUBLED is set to blank. If the SQLWARN bind option is YES, a warning SQLCODE +239 (SQLSTATE 01005) is issued.
Allocate 2*SQLD SQLVAR entries for a successful DESCRIBE, including the names of the distinct types.
No SQLVAR entries are set and SQLDOUBLED is set to blank. A warning SQLCODE +238 (SQLSTATE 01005) is issued (regardless of the setting of the SQLWARN bind option).
Allocate 2*SQLD SQLVAR entries for a successful DESCRIBE.
The SQLWARN option of the BIND command cannot control whether the DESCRIBE (or PREPARE...INTO) will return the following warnings:
It is recommended that your application code always consider that these SQLCODE values could be returned. The warning SQLCODE +238 (SQLSTATE 01005) is always returned when there are LOB columns in the select list and there are insufficient SQLVAR entries in the SQLDA. This is the only way the application can know that the number of SQLVAR entries must be doubled because of a LOB column in the result set.