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.

Table 1. Contents of SQLVAR arrays
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:
  1. DESCRIBE INPUT does not return information about distinct types.
  2. The number of columns or host variables that the SQLDA describes.
  3. Either LOBs, distinct types, or both are present.
  4. Here, the 7th byte is set to a space and SQLD is set to two times the number of columns in the result. For all other values of the 7th byte for USING BOTH, SQLD is set to the number of columns in the result, and the 7th byte can be used to determine how many SQLVAR entries are needed for each column of the result.
1 DESCRIBE INPUT does not return information about distinct types.
2 When an extended SQLVAR entry is present for each column for labels (and there are no LOB or distinct type columns in the result),