DB2 10.5 for Linux, UNIX, and Windows

Declaring the SQLDA structure in a dynamically executed SQL program

An SQLDA contains a variable number of occurrences of SQLVAR entries, each of which contains a set of fields that describe one column in a row of data. There are two types of SQLVAR entries: base SQLVAR entries and secondary SQLVAR entries.

About this task

The following diagram describes the structure of the SQLDA.
Figure 1. The SQL Descriptor Area (SQLDA)
The SQL Descriptor Area (SQLDA)

Because the number of SQLVAR entries required depends on the number of columns in the result table, an application must be able to allocate an appropriate number of SQLVAR elements when needed. Use one of the following methods:

Procedure

What to do next

For all three methods, the question arises as to how many initial SQLVAR entries you should allocate. Each SQLVAR element uses up 44 bytes of storage (not counting storage allocated for the SQLDATA and SQLIND fields). If memory is plentiful, the first method of providing an SQLDA of maximum size is easier to implement.

The second method of allocating a smaller SQLDA is only applicable to programming languages such as C and C++ that support the dynamic allocation of memory. For languages such as COBOL and FORTRAN that do not support the dynamic allocation of memory, use the first method.