Allocating an SQLDA structure with sufficient SQLVAR entries for dynamically executed SQL statements
About this task
Assume that the result table contains 20 columns (none
of which are LOB columns). In this situation, you must allocate a
second SQLDA structure, fulsqlda
with at least 20
SQLVAR elements (or 40 elements if the result table contains any LOBs
or distinct types). For the rest of this example, assume that no LOBs
or distinct types are in the result table.
Procedure
- A fixed-length header, 16 bytes in length, containing fields such as SQLN and SQLD
- A variable-length array of SQLVAR entries, of which each element is 44 bytes in length on 32-bit platforms, and 56 bytes in length on 64-bit platforms.
What to do next
The number of SQLVAR entries needed for fulsqlda
is
specified in the SQLD field of minsqlda
. Assume
this value is 20. Therefore, the storage allocation required for fulsqlda
is:
16 + (20 * sizeof(struct sqlvar))
This value represents the size of the header plus 20 times the size of each SQLVAR entry, giving a total of 896 bytes.
You can use the SQLDASIZE macro to avoid doing your own calculations and to avoid any version-specific dependencies.