Field descriptions in an occurrence of SQLVAR

This section includes field descriptions in an occurrence of a base and secondary SQLVAR.

Fields in an occurrence of a base SQLVAR

 

Table 1. Field Descriptions for an SQLVAR

C Name 1
COBOL Name
PL/I Name
RPG Name

Field
Data Type

Usage in DESCRIBE and PREPARE (set by the database manager) Usage in FETCH, OPEN, CALL, and EXECUTE (set by the user prior to executing the statement)

sqltype
SQLTYPE

SMALLINT Indicates the data type of the column and whether it can contain nulls. For a description of the type codes, see Table 1.

For a distinct type, the data type on which the distinct type is based is placed in this field. The base SQLVAR contains no indication that this is part of the description of a distinct type.

Indicates the data type of the host variable and whether an indicator variable is provided. For a description of the type codes, see Table 1.

sqllen
SQLLEN

SMALLINT The length attribute of the column. For datetime columns, the length of the string representation of the values. See Table 1.

Start of changeFor a LOB, the value is 0 regardless of the length attribute of the LOB. For XML, the value is 0. Field SQLLONGLEN in the extended SQLVAR entry contains the length attribute of the LOB or XML.End of change

The length attribute of the host variable. See Table 1.

Start of changeFor a LOB, the value is 0 regardless of the length attribute of the LOB. Field SQLLONGLEN in the extended SQLVAR entry contains the length attribute of the LOB.End of change

Start of changeFor XML AS BLOB, CLOB, or DBCLOB, the value is 0.End of change

sqlres
SQLRES

CHAR(12) Reserved. Provides boundary alignment for SQLDATA. Reserved. Provides boundary alignment for SQLDATA.
Start of change

sqldata
SQLDATA

End of change
Start of changepointerEnd of change Start of changeThe CCSID of a string column or XML column as described in Table 1.End of change Start of changeContains the address of the host variable.

For LOB host variables, if the SQLDATALEN field in the extended SQLVAR is null, this points to the four-byte LOB length, followed immediately by the LOB data.

If the SQLDATALEN field in the extended SQLVAR is not null, this points to the LOB data and the SQLDATALEN field points to the four-byte LOB length.

End of change

sqlind
SQLIND

pointer For a select-statement, indicates whether the column was added as a result of using the WITH ROW CHANGE COLUMNS attribute:
  • -1 ROW CHANGE TOKEN (distinct)
  • -2 ROW CHANGE TOKEN (not distinct)
  • -3 RID
  • -4 RID_BIT
Otherwise, reserved.
Contains the address of the indicator variable. Not used if there is no indicator variable (as indicated by an even value of SQLTYPE).
Start of change

sqlname
SQLNAME

End of change
Start of changeVARCHAR(30)End of change Start of changeThe unqualified name of the column. If the column does not have a name, a string is constructed from the expression and returned.

The name is case sensitive and does not contain surrounding delimiters.

End of change
Start of changeContains the CCSID of the host variable as described in Table 1.

For XML data, sqlname can be set as follows to indicate as XML subtype:

The length of sqlname is 8

Bytes 1 and 2: Must be X'0000'.

Bytes 3 and 4: May contain a CCSID.

Bytes 5 and 6 X'0100' XML host variable (XML AS CLOB, XML AS DBCLOB, XML AS BLOB, XML AS CLOB_FILE, XML AS DBCLOB_FILE, XML AS BLOB_FILE)

Bytes 7 and 8: Must be X'0000'.

End of change

Fields in an occurrence of a secondary SQLVAR

 

Table 2. Field Descriptions for an Extended SQLVAR

C Name 2
COBOL Name
PL/I Name
RPG Name

Field
Data Type

Usage in DESCRIBE and PREPARE (set by the database manager) Usage in FETCH, OPEN, CALL, and EXECUTE (set by the user prior to executing the statement)
Start of change

len.sqllonglen
SQLLONGL
SQLLONGLEN

End of change
Start of changeINTEGEREnd of change Start of changeThe length attribute of a LOB column. For XML, the value is 0.End of change Start of changeThe length attribute of a LOB or XML host variable. The database manager ignores the SQLLEN field in the base SQLVAR for these data types. The length attribute indicates the number of bytes for a BLOB, and the number of characters for a CLOB, DBCLOB, or for XML.End of change
* CHAR(12) Reserved. Provides boundary alignment for SQLDATALEN. Reserved. Provides boundary alignment for SQLDATALEN.
* pointer Reserved. Reserved.

sqldatalen
SQLDATAL
SQLDATALEN

pointer Not used. Used only for LOB host variables.

If the value of this field is not null, this field points to a four-byte long buffer that contains the actual length of the LOB in bytes (even for DBCLOBs). The SQLDATA field in the matching base SQLVAR then points to the LOB data.

If the value of this field is null, the actual length of the LOB is stored in the first four bytes pointed to by the SQLDATA field in the matching base SQLVAR, and the LOB data immediately follows the four-byte length. The actual length indicates the number of bytes for a BLOB or CLOB and the number of double-byte characters for a DBCLOB.

Regardless of whether this field is used, field SQLLONGLEN must be set.

sqldatatype_name
SQLTNAME
SQLDATATYPE-NAME

VARCHAR (30) The SQLTNAME field of the extended SQLVAR is set to one of the following:
  • For a distinct type column, the database manager sets this to the fully qualified distinct type name. If the qualified name is longer than 30 bytes, it is truncated.
  • For a label, the database manager sets this to the first 20 bytes of the label.
  • For a column name, the database manager sets this to the column name.
Not used.
1 In this column, the lowercase name is the C Name. The uppercase name is the PL/I, COBOL, and RPG Name.
2 In this column, the lowercase name is the C Name. The first uppercase name is the PL/I and RPG Name. The second uppercase name is the COBOL Name.