The DESCRIBE statement gets information about the host variables required to store data retrieved from the database, or host variables required to pass data to the database.
The following table indicates the values of the sqllen and sqltype structure members returned by the DESCRIBE statement for the various database types (both SELECT LIST and BIND VARIABLE DESCRIBE statements). For a user-defined database data type, the base type is described.
Your program can use the types and lengths returned from a DESCRIBE, or you may use another type. The database server performs type conversions between any two types. The memory pointed to by the sqldata field must correspond to the sqltype and sqllen fields. The embedded SQL type is obtained by a bitwise AND of sqltype with DT_TYPES (sqltype & DT_TYPES).
Database field type | Embedded SQL type returned | Length (in bytes) returned on describe |
---|---|---|
BIGINT | DT_BIGINT | 8 |
BINARY(n) | DT_BINARY | n |
BIT | DT_BIT | 1 |
CHAR(n) | DT_FIXCHAR1 | n times maximum data expansion when converting from database character set to the client's CHAR character set. If this length would be more than 32767 bytes, then the embedded SQL type returned is DT_LONGVARCHAR with a length of 32767 bytes. |
CHAR(n CHAR) | DT_FIXCHAR1 | n times maximum character length in the client's CHAR character set. If this length would be more than 32767 bytes, then the embedded SQL type returned is DT_LONGVARCHAR with a length of 32767 bytes. |
DATE | DT_DATE | length of longest formatted string |
DECIMAL(p,s) | DT_DECIMAL | low byte of length field in SQLDA set to p, and high byte set to s. See PRECISION and SCALE macros in sqlda.h. |
DOUBLE | DT_DOUBLE | 8 |
FLOAT | DT_FLOAT | 4 |
INT | DT_INT | 4 |
LONG BINARY | DT_LONGBINARY | 32767 |
LONG NVARCHAR | DT_LONGVARCHAR / DT_LONGNVARCHAR2 | 32767 |
LONG VARCHAR | DT_LONGVARCHAR | 32767 |
NCHAR(n) | DT_FIXCHAR / DT_NFIXCHAR2 | n times maximum character length in the client's NCHAR character set. If this length would be more than 32767 bytes, then the embedded SQL type returned is DT_LONGNVARCHAR with a length of 32767 bytes. |
NVARCHAR(n) | DT_VARCHAR / DT_NVARCHAR2 | n times maximum character length in the client's NCHAR character set. If this length would be more than 32767 bytes, then the embedded SQL type returned is DT_LONGNVARCHAR with a length of 32767 bytes. |
REAL | DT_FLOAT | 4 |
SMALLINT | DT_SMALLINT | 2 |
TIME | DT_TIME | length of longest formatted string |
TIMESTAMP | DT_TIMESTAMP | length of longest formatted string |
TINYINT | DT_TINYINT | 1 |
UNSIGNED BIGINT | DT_UNSBIGINT | 8 |
UNSIGNED INT | DT_UNSINT | 4 |
UNSIGNED SMALLINT | DT_UNSSMALLINT | 2 |
VARCHAR(n) | DT_VARCHAR1 | n times maximum data expansion when converting from database character set to the client's CHAR character set. If this length would be more than 32767 bytes, then the embedded SQL type returned is DT_LONGVARCHAR with a length of 32767 bytes. |
VARCHAR(n CHAR) | DT_VARCHAR1 | n times maximum character length in the client's CHAR character set. If this length would be more than 32767, then the embedded SQL type returned is DT_LONGVARCHAR with length 32767. |
1 The type returned for CHAR and VARCHAR may be DT_LONGVARCHAR if the maximum byte length in the client's CHAR character set is greater than 32767 bytes.
2 The type returned for NCHAR and NVARCHAR may be DT_LONGNVARCHAR if the maximum byte length in the client's NCHAR character set is greater than 32767 bytes. NCHAR, NVARCHAR, and LONG NVARCHAR are described by default as either DT_FIXCHAR, DT_VARCHAR, or DT_LONGVARCHAR, respectively. If the db_change_nchar_charset function has been called, the types are described as DT_NFIXCHAR, DT_NVARCHAR, and DT_LONGNVARCHAR, respectively.