SQLVAR entries in the SQLDA
For each column or host variable described by the SQLDA, there are both base SQLVAR entries and extended SQLVAR entries.
- Base SQLVAR entry
- The base SQLVAR entry is always present. The fields of this entry contain the base information about the column or host variable such as data type code, length attribute (except for LOBs), column name (or label), host variable address, and indicator variable address.
- Extended SQLVAR entry
- The extended SQLVAR entry is needed (for each column) if the result includes any LOB or distinct type1 columns. For distinct types, the extended SQLVAR contains the distinct type name. For LOBs, the extended SQLVAR contains the length attribute of the host variable and a pointer to the buffer that contains the actual length. If locators are used to represent LOBs, an extended SQLVAR is not necessary.
The extended SQLVAR entry is also needed for each column when the USING BOTH clause was specified, which indicates that both columns names and labels are returned. The DESCRIBE output and PREPARE statements can include the USING BOTH clause.
The fields in the extended SQLVAR that return LOB and distinct type information do not overlap, and the fields that return LOB and label information do not overlap. Depending on the combination of labels, LOBs and distinct types, more than one extended SQLVAR entry per column may be required to return the information. See Determining how many SQLVAR occurrences are needed.
The following table shows how to map the base and extended SQLVAR entries. For an SQLDA that contains both base and extended SQLVAR entries, the base SQLVAR entries are in the first block, followed by a block of extended SQLVAR entries, which if necessary, are followed by a second block of extended SQLVAR entries. In each block, the number of occurrences of the SQLVAR entry is equal to the value in SQLD2 even though many of the extended SQLVAR entries might be unused.
LOBs | Distinct
types1 |
7th byte of SQLDAID | SQLD | Minimum for SQLN2 | Set of SQLVAR entries | ||
---|---|---|---|---|---|---|---|
First set
(Base) |
Second set
(Extended) |
Third set
(Extended) |
|||||
USING BOTH clause not specified: | |||||||
No | No | Space | n | n | Column names,
labels |
Not Used | Not Used |
Yes3 | Yes3 | 2 | n | 2n | Column names,
labels |
LOBs,
distinct types, or both |
Not used |
USING BOTH clause was specified: | |||||||
No | No | Space | 2n | 2n | Column names | Labels | Not used |
Yes | No | 2 | n | 2n | Column names | LOBs and labels | Not used |
No | Yes | 3 | n | 3n | Column names | Distinct types | Labels |
Yes | Yes | 3 | n | 3n | Column names | LOBs and
distinct types |
Labels |
Notes:
|