Open Client has three character types, CS_CHAR, CS_LONGCHAR, and CS_VARCHAR:
CS_CHAR corresponds to the Adaptive Server types char and varchar. That is, Client-Library interprets both the server char and varchar types as CS_CHAR. For example, ct_describe returns CS_CHAR_TYPE when describing a result column that has the server datatype varchar.
CS_CHAR is defined as:
typedef char CS_CHAR;
WARNING! CS_LONGCHAR and CS_VARCHAR do not correspond to any SQL Server datatypes. Specifically, CS_VARCHAR does not correspond to the SQL Server datatype varchar.
CS_LONGCHAR does not correspond to any SQL Server type, but some Open Server applications support CS_LONGCHAR. An application uses the CS_DATA_LCHAR capability to determine whether an Open Server connection supports CS_LONGCHAR. If it does, then ct_describe returns CS_LONGCHAR when describing a result data item.
A CS_LONGCHAR value has a maximum length of 2,147,483,647 bytes. CS_LONGCHAR is defined as:
typedef unsigned char CS_LONGCHAR;
CS_VARCHAR does not correspond to any SQL Server type. For this reason, Open Client routines do not return CS_VARCHAR_TYPE. CS_VARCHAR is provided to enable non-C programming language veneers to be written for Open Client. Typical client applications will not use CS_VARCHAR.
CS_VARCHAR is defined as:
typedef struct _cs_varchar
{
CS_SMALLINT len;
CS_CHAR str[CS_MAX_CHAR];
} CS_VARCHAR;
where:
len is the length of the string.
str is the string itself. Note that str is not null-terminated.
Although CS_VARCHAR variables are used to store variable-length values, CS_VARCHAR is considered to be a fixed-length type. This means that an application does not typically need to provide Client-Library with the length of a CS_VARCHAR variable. For example, ct_bind ignores the value of datafmt−>maxlength when binding to a CS_VARCHAR variable.