Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 12.0.0 » SQL Anywhere Server - Programming » Embedded SQL » The SQL descriptor area (SQLDA) » SQLDA sqllen field values

 

Describing values

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).

For information about embedded SQL data types, see Embedded SQL data 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_FIXCHAR2 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_FIXCHAR2 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 high byte of length field in SQLDA set to p, and low byte set to s
DOUBLE DT_DOUBLE 8
FLOAT DT_FLOAT 4
INT DT_INT 4
LONG BINARY DT_LONGBINARY 32767
LONG NVARCHAR DT_LONGNVARCHAR1 32767
LONG VARCHAR DT_LONGVARCHAR 32767
NCHAR(n) DT_NFIXCHAR1 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_NVARCHAR1 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_VARCHAR2 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_VARCHAR(2) 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 NCHAR and NVARCHAR may be DT_LONGNVARCHAR if the maximum byte length in the client's NCHAR character set is greater than 32767 bytes. For examples of the results returned when a DESCRIBE is performed, see NCHAR data type and NVARCHAR data type.

In embedded SQL, 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. See db_change_nchar_charset function.

2 The type returned may be DT_LONGVARCHAR if the maximum byte length in the client's CHAR character set is greater than 32767 bytes. For examples of the results returned when a DESCRIBE is performed, see CHAR data type and VARCHAR data type.