Field descriptions in an SQLDA header

An SQLDA consists of four variables in a header structure followed by an arbitrary number of occurrences of a sequence of five variables collectively named SQLVAR. In OPEN, CALL, FETCH, and EXECUTE, each occurrence of SQLVAR describes a variable. In PREPARE and DESCRIBE, each occurrence describes a column of a result table.

The SQL INCLUDE statement provides the following field names:

Table 92. Field Descriptions for an SQLDA Header
C Name 103
PL/I Name
COBOL Name
Field
Data Type
Usage in DESCRIBE and PREPARE (set by the database manager except for SQLN) Usage in FETCH, OPEN, CALL, or EXECUTE (set by the user prior to executing the statement)
sqldaid
SQLDAID
CHAR(8) An 'eye catcher' for storage dumps, containing 'SQLDA '.

The 7th byte of the SQLDAID can be used to determine whether more than one SQLVAR entry is needed for each column. For details, see Determining how many SQLVAR occurrences are needed.

A '2' in the 7th byte indicates that two SQLVAR entries were allocated for each column.

A '3' in the 7th byte indicates that three SQLVAR entries were allocated for each column.

A '4' in the 7th byte indicates that four SQLVAR entries were allocated for each column.

sqldabc
SQLDABC
INTEGER Length of the SQLDA. Number of bytes of storage allocated for the SQLDA. Enough storage must be allocated to contain SQLN occurrences. SQLDABC must be set to a value greater than or equal to 16+SQLN*(80), where 80 is the length of an SQLVAR occurrence. If LOBs or distinct types are specified, there must be two SQLVAR entries for each parameter marker.
sqln
SQLN
SMALLINT Unchanged by the database manager. Must be set to a value greater than or equal to zero before the PREPARE or DESCRIBE statement is executed. It should be set to a value that is greater than or equal to the number of columns in the result or a multiple of the number of columns in the result when multiple sets of SQLVAR entries are necessary. Indicates the total number of occurrences of SQLVAR. Total number of occurrences of SQLVAR provided in the SQLDA. SQLN must be set to a value greater than or equal to zero.

If LOBs or distinct types are specified, there must be two SQLVAR entries for each parameter marker and SQLN must be set to two times the number of parameter markers.

sqld
SQLD
SMALLINT The number of columns described by occurrences of SQLVAR (zero if the statement being described is not a select-statement). Number of occurrences of SQLVAR entries in the SQLDA that are used when executing the statement. SQLD must be set to a value greater than or equal to zero and less than or equal to SQLN.

Determining how many SQLVAR occurrences are needed

The number of SQLVAR occurrences needed depends on the statement that the SQLDA was provided for and the data types of the columns or parameters being described. See the tables above for more information.

The 7th byte of SQLDAID is always set to the number of sets of SQLVARs necessary.

If SQLD is not set to a sufficient number of SQLVAR occurrences:

Table 93, Table 94, and Table 95 show 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 or third block of extended SQLVAR entries. In each block, the number of occurrences of the SQLVAR entry is equal to the value in SQLD even though many of the extended SQLVAR entries might be unused.

Table 93. Contents of SQLVAR Arrays for USING NAMES, USING SYSTEM NAMES, USING LABELS or USING ANY
LOBs DISTINCT types 7th byte of SQLDAID SQLN Minimum First Set (Base) Second Set (Extended) Third Set (Extended) Fourth Set (Extended)
No No Blank n Column names, system column names, or labels Not used Not used Not used
Yes No 2 2n Column names, system column names, or labels LOBs Not used Not used
No Yes 2 2n Column names, system column names, or labels Distinct types Not used Not used
Yes Yes 2 2n Column names, system column names, or labels LOBs and distinct types Not used Not used

 

Table 94. Contents of SQLVAR Arrays for USING BOTH
LOBs DISTINCT types 7th byte of SQLDAID SQLN Minimum First Set (Base) Second Set (Extended) Third Set (Extended) Fourth Set (Extended)
No No 2 2n Column names Labels Not used Not used
Yes No 2 2n Column names LOBs and labels Not used Not used
No Yes 3 3n Column names Distinct types Labels Not used
Yes Yes 3 3n Column names LOBs and distinct types Labels Not used

 

Table 95. Contents of SQLVAR Arrays for USING ALL
LOBs DISTINCT types 7th byte of SQLDAID SQLN Minimum First Set (Base) Second Set (Extended) Third Set (Extended) Fourth Set (Extended)
No No 3 3n System column names Labels Column names Not used
Yes No 3 3n System column names LOBs and labels Column names Not used
No Yes 4 4n System column names Distinct types Labels Column names
Yes Yes 4 4n System column names LOBs and distinct types Labels Column names

103.
In this column, the lowercase name is the C Name. The uppercase name is the COBOL, PL/I, or RPG Name.



[ Top of Page | Previous Page | Next Page | Contents | Index ]