SQLTYPE and SQLLEN

The contents of the SQLTYPE and SQLLEN fields of the SQLDA depends on the SQL statement that is returning the value.

The following table shows the values that can appear in the SQLTYPE and SQLLEN fields of the SQLDA. In DESCRIBE and PREPARE INTO, an even value of SQLTYPE means the column does not allow nulls, and an odd value means the column does allow nulls. In DESCRIBE INPUT statements, only odd values are returned for SQLTYPE. In FETCH, OPEN, EXECUTE, and CALL, 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.

Table 1. SQLTYPE and SQLLEN values for DESCRIBE, PREPARE INTO, FETCH, OPEN, EXECUTE, and CALL
SQLTYPE For DESCRIBE and PREPARE INTO For FETCH, OPEN, EXECUTE, and CALL
Column or parameter data type SQLLEN Host variable data type SQLLEN
384/385 date 10 1 fixed-length character string representation of a date length attribute of the host variable
388/389 time 2 fixed-length character string representation of a time length attribute of the host variable
Start of change392/393End of change Start of changetimestamp without time zoneEnd of change Start of change19 for TIMESTAMP(0) otherwise 20+p for TIMESTAMP(p) 5End of change Start of changefixed-length character string representation of a timestampEnd of change Start of changelength attribute of the host variableEnd of change
400/401 N/A N/A NUL-terminated graphic string length attribute of the host variable
404/405 BLOB 0 3 BLOB or XML AS BLOB Not used. 3
408/409 CLOB 0 3 CLOB or XML AS CLOB Not used. 3
412/413 DBCLOB 0 3 DBCLOB or XML AS DBCLOB Not used. 3
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

SQLTYPE values 448/449 are returned instead of 456/457 for statements that are bound in Version 9 or later.

length attribute of the column long varying-length character string length attribute of the host variable
460/461 N/A N/A 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 graphic string

SQLTYPE values 464/465 are returned instead of 472/473 for statements that are bound in Version 9 or later.

length attribute of the column long graphic 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
492/493 big integer4 8 big integer 8
496/497 large integer 4 large integer 4
500/501 small integer 2 small integer 2
504/505 N/A N/A
DISPLAY SIGN
LEADING SEPARATE,
NATIONAL 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 BLOB_FILE 267    
920/921 CLOB_FILE 267    
924/925 DBCLOB_FILE 267    
960/961 BLOB locator 4 BLOB_LOCATOR 4
964/965 CLOB locator 4 CLOB_LOCATOR 4
968/969 DBCLOB locator 4 DBCLOB_LOCATOR 4
988/989 XML 0 Invalid. Instead, use one of the following: XML AS BLOB, XML AS CLOB, XML AS DBCLOB Not used
996/997
DECFLOAT(16)
DECFLOAT(34)
8
16
DECFLOAT(16)
DECFLOAT(34)
8
16
Start of change2448/2449End of change Start of changetimestamp with time zoneEnd of change Start of change147 for TIMESTAMP(0) WITH TIME ZONE otherwise 148+p for TIMESTAMP(p) WITH TIME ZONE 5End of change Start of changevarying-length character string representation of a timestamp with time zoneEnd of change Start of changelength attribute of the host variableEnd of change
Note:
  1. SQLLEN might be different if a date installation exit is specified.
  2. SQLLEN might be different if a time installation exit is specified.
  3. Start of changeField SQLLONGLEN in the extended SQLVAR contains the length attribute of the column. In REXX, the SQLVAR length attribute field name is SQLLONGL and SQLLEN is not used.End of change
  4. BIGINT is supported by other DB2® platforms.
  5. p is the timestamp precision.