Datatype mappings

Table 1-1 describes the Adaptive Server ODBC Driver datatype mappings.

Table 1-1: Datatype mappings

ASE datatype

ODBC SQL datatype

ODBC bind datatype

bigdatetime

SQL_TYPE_TIMESTAMP

SQL_C_TYPE_TIMESTAMP or SQL_C_CHAR

bigtime

SQL_TYPE_TIME

SQL_C_TYPE_TIME or SQL_C_CHAR

bigint

SQL_BIGINT

SQL_C_BIGINT

binary

SQL_BINARY

SQL_C_BINARY

bit

SQL_BIT

SQL_C_BIT

char

SQL_CHAR

SQL_C_CHAR

date

SQL_TYPE_DATE

SQL_C_TYPE_DATE or SQL_C_CHAR

datetime

SQL_TYPE_TIMESTAMP

SQL_C_TYPE_TIMESTAMP or SQL_C_CHAR

decimal

SQL_DECIMAL

SQL_C_NUMERIC or SQL_C_CHAR

double

SQL_DOUBLE

SQL_C_DOUBLE

float(<16)

SQL_REAL

SQL_C_FLOAT

float(>=16)

SQL_DOUBLE

SQL_C_DOUBLE

image

SQL_LONGVARBINARY

SQL_C_BINARY

int[eger]

SQL_INTEGER

SQL_C_LONG

money

SQL_DECIMAL

SQL_C_NUMERIC or SQL_C_CHAR

nchar

SQL_CHAR

SQL_C_CHAR

nvarchar

SQL_VARCHAR

SQL_C_CHAR

numeric

SQL_NUMERIC

SQL_C_NUMERIC or SQL_C_CHAR

real

SQL_REAL

SQL_C_FLOAT

smalldatetime

SQL_TYPE_TIMESTAMP

SQL_C_TYPE_TIMESTAMP or SQL_C_CHAR

smallint

SQL_SMALLINT

SQL_C_SHORT

smallmoney

SQL_DECIMAL

SQL_C_NUMERIC or SQL_C_CHAR

text

SQL_LONGVARCHAR

SQL_C_CHAR

time

SQL_TYPE_TIME

SQL_C_TYPE_TIME or SQL_C_CHAR

timestamp

SQL_BINARY

SQL_C_BINARY

tinyint

SQL_TINYINT

SQL_C_TINYINT

unichar

SQL_WCHAR

SQL_C_CHAR

unitext

SQL_WLONGVARCHAR

SQL_C_CHAR

univarchar

SQL_WVARCHAR

SQL_C_CHAR

unsignedbigint

SQL_BIGINT

SQL_C_UBIGINT

unsignedint

SQL_INTEGER

SQL_C_ULONG

unsignedsmallint

SQL_SMALLINT

SQL_C_USHORT

varbinary

SQL_VARBINARY

SQL_C_BINARY

varchar

SQL_VARCHAR

SQL_C_CHAR

Special instructions for unichar, varchar, and unitext

When you use the Adaptive Server datatypes unichar, univarchar, and unitext, and then bind any of them to SQL_C_CHAR, the Adaptive Server ODBC Driver must convert the data from Unicode to multibyte and vice versa. For this conversion, it must have the SYBASE charsets installed in the $SYBASE directory. The installation program includes an option to install these charset files.

If the driver does not find the charsets, or if the $SYBASE environment variable is not set, then an appropriate error is propagated to the application. To install the SYBASE charsets, you must reinstall the ODBC Driver. See the Software Developer’s Kit and Open Server Installation Guide for your platform.

NoteTo support older applications, the Adaptive Server ODBC Driver assumes that the default type is SQL_C_CHAR when a unitext, univarchar, or unichar column is bound as SQL_C_DEFAULT. To bind as unicode, the application must explicitly use a bind type of SQL_C_WCHAR.