Field descriptions of an occurrence of a base SQLVAR
The fields of a base SQLVAR have different uses depending on the SQL statement.
The following table describes the contents of the fields of a base SQLVAR.
C name
assembler COBOL, or PL/I name |
Data
type |
Usage in DESCRIBE1
and PREPARE INTO |
Usage in FETCH, OPEN,
EXECUTE, and CALL |
---|---|---|---|
sqltype
SQLTYPE |
SMALLINT | Indicates the data type of the column or parameter and
whether it can contain null values. For a description of the type codes, see Table 1. For a distinct type, the data type on which the distinct type was based is placed in this field. The base SQLVAR provides 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. Host variables for datetime values must be character string variables. For FETCH, a datetime type code means a fixed-length character string. For a description of the type codes, see SQLTYPE and SQLLEN. |
sqllen
SQLLEN |
SMALLINT | The length attribute
of the column or parameter. For datetime data, the length of the string
representation of the value. See SQLTYPE and SQLLEN for
a description of allowable values. For LOBs, the value is 0 regardless of the length attribute of the LOB. For XML, the value is 0. Field SQLLONGLEN in the extended SQLVAR contains the length attribute. |
The length attribute
of the host variable. See SQLTYPE and SQLLEN for
a description of allowable values. For LOBs, the value is 0 regardless of the length attribute of the LOB. Field SQLLONGLEN in the extended SQLVAR contains the length attribute. For XML AS BLOB, CLOB, or DBCLOB, sqllen is 0 as for LOB types. |
sqldata
SQLDATA |
pointer | For string columns or parameters, SQLDATA contains
X'0000zzzz', where zzzz is the
associated CCSID. For character strings, SQLDATA can alternatively contain X'FFFF', which
indicates bit data. Not used for other types of data. For datetime columns, SQLDATA can contain the CCSID of the string representation of the datetime value. For DESCRIBE PROCEDURE, the result set locator value associated with the result set. |
Contains the address of the host variable. |
sqlind
SQLIND |
pointer | Reserved For DESCRIBE PROCEDURE, it is set to -1. |
Contains the address of an associated indicator variable, if SQLTYPE is odd. Otherwise, the field is not used. |
sqlname
SQLNAME |
VARCHAR(30) | Contains the unqualified
name or label of the column, or a string of length zero if the name
or label does not exist. If the name is longer than 30 bytes, it is
truncated at a byte boundary. For more information about column
names, see Names
of result columns. For DESCRIBE PROCEDURE, SQLNAME contains the cursor name used by the stored procedure to return the result set. The values for SQLNAME appear in the order the cursors were opened by the stored procedure. For DESCRIBE INPUT, SQLNAME is not used. |
Can contain CCSID and/or
host-variable-array dimension information. DB2® interprets the third and fourth byte of the
data portion of SQLNAME as the CCSID of the host variable if all
of the following are true and the third and fourth byte are not X'0000':
For FETCH, OPEN, INSERT, and EXECUTE, if the length of SQLNAME is 8, and the first two bytes of the data portion of SQLNAME are X'0000', DB2 interprets the fifth through eighth bytes of the data portion of the SQLNAME field as follows: |
(cont.)
sqlname SQLNAME |
|
||
Notes:
|