SQLTYPE and SQLLEN
The following table shows the values that may appear in the SQLTYPE and SQLLEN fields of the SQLDA. In PREPARE and DESCRIBE, an even value of SQLTYPE means the column does not allow nulls, and an odd value means the column does allow nulls.
Note: In an SQLDA used in DESCRIBE or PREPARE statements,
an odd value is returned for an expression if one operand is nullable
or if the expression may result in a -2 mapping-error null value.
In FETCH, OPEN, CALL, and EXECUTE, an even value of SQLTYPE means no indicator variable is provided, and an odd value means that SQLIND contains the address of an indicator variable.
SQLTYPE | For PREPARE and DESCRIBE | For FETCH, OPEN, CALL, and EXECUTE | ||
---|---|---|---|---|
COLUMN DATA TYPE | SQLLEN | HOST VARIABLE DATA TYPE | SQLLEN | |
384/385 | Date 3 | 10 | Fixed-length character-string representation of a date | Length attribute of the host variable |
388/389 | Time | 8 | Fixed-length character-string representation of a time | Length attribute of the host variable |
392/393 | Timestamp | 19 for TIMESTAMP(0)
otherwise 20+p for TIMESTAMP(p) |
Fixed-length character-string representation of a timestamp | Length attribute of the host variable |
396/397 | DataLink | Length attribute of the column | DataLink | Length attribute of the host variable |
400/401 | Not Applicable | Not Applicable | NUL-terminated graphic string | Length attribute of the host variable |
404/405 | BLOB | 0 2 | BLOB | Not used. 2 |
408/409 | CLOB | 0 2 | CLOB | Not used. 2 |
412/413 | DBCLOB | 0 2 | DBCLOB | Not used. 2 |
448/449 | Varying-length character string | Length attribute of the column | Varying-length character string | Length attribute of the host variable |
452/453 | Fixed-length character string | Length attribute of the column | Fixed-length character string | Length attribute of the host variable |
456/457 | Long varying-length character string | Length attribute of the column | Long varying-length character string | Length attribute of the host variable |
460/461 | Not Applicable | Not Applicable | NUL-terminated character string | Length attribute of the host variable |
464/465 | Varying-length graphic string | Length attribute of the column | Varying-length graphic string | Length attribute of the host variable |
468/469 | Fixed-length graphic string | Length attribute of the column | Fixed-length graphic string | Length attribute of the host variable |
472/473 | Long varying-length graphic string | Length attribute of the column | Long graphic string | Length attribute of the host variable |
476/477 | Not Applicable | Not Applicable | PASCAL L-string | Length attribute of the host variable |
480/481 | Floating point | 4 for single precision, 8 for double precision | Floating point | 4 for single precision, 8 for double precision |
484/485 | Packed decimal | Precision in byte 1; scale in byte 2 | Packed decimal | Precision in byte 1; scale in byte 2 |
488/489 | Zoned decimal | Precision in byte 1; scale in byte 2 | Zoned decimal | Precision in byte 1; scale in byte 2 |
492/493 | Big integer | 8 1 | Big integer | 8 |
496/497 | Large integer | 4 1 | Large integer | 4 |
500/501 | Small integer | 2 1 | Small integer | 2 |
504/505 | Not Applicable | Not Applicable | DISPLAY SIGN LEADING SEPARATE | Precision in byte 1; scale in byte 2 |
904/905 | ROWID | 40 | ROWID | 40 |
908/909 | Varying-length binary string | Length attribute of the column | Varying-length binary string | Length attribute of the host variable |
912/913 | Fixed-length binary string | Length attribute of the column | Fixed-length binary string | Length attribute of the host variable |
916/917 | Not Applicable | Not Applicable | BLOB file reference variable | 267 |
920/921 | Not Applicable | Not Applicable | CLOB file reference variable | 267 |
924/925 | Not Applicable | Not Applicable | DBCLOB file reference variable | 267 |
960/961 | Not Applicable | Not Applicable | BLOB locator | 4 |
964/965 | Not Applicable | Not Applicable | CLOB locator | 4 |
968/969 | Not Applicable | Not Applicable | DBCLOB locator | 4 |
972 | Not Applicable | Not Applicable | Result set locator | 8 |
988/989 | XML | 0 | Not Applicable. Use XML AS CLOB, XML AS DBCLOB, or XML AS BLOB | 0 |
996/997 | Not Applicable
DECFLOAT(16) DECFLOAT(34) |
Not Applicable
8 16 |
4
8 16 |
|
2452/2453 | Not Applicable | Not Applicable | XML locator | 4 |
1 Binary numbers can be represented in the
SQLDA with a length of 2, 4, or 8, or with the precision in byte 1
and the scale in byte 2. If the first byte is greater than x'00',
it indicates precision and scale.
2 Field SQLLONGLEN in the extended SQLVAR contains
the length attribute of the column.
4 DB2® does
not internally store DECFLOAT(7) numbers, but it will support DECFLOAT(7)
numbers from applications. A DECFLOAT(7) variable referenced in an
SQL statement will be converted to DECFLOAT(16).