An application that needs to use a datatype that is not included in the standard Open Client type set may create a user-defined datatype.
A Client-Library application creates a user-defined type by declaring it:
typedef char CODE_NAME;
The Open Client routines ct_bind and cs_set_convert use integer symbolic constants to identify datatypes, so it is often convenient for an application to declare a type constant for a user-defined type. User-defined types must be defined as greater than or equal to CS_USERTYPE:
#define CODE_NAME_TYPE (CS_USERTYPE + 2)
Once a user-defined type has been created, an application:
Calls cs_set_convert to install custom conversion routines to convert between standard Open Client types and the user-defined type
Calls cs_setnull to define a null substitution value for the user-defined type.
After conversion routines are installed, an application binds server results to a user-defined type:
mydatafmt.datatype = CODE_NAME_TYPE;
ct_bind(cmd, 1, &mydatafmt, mycodename, NULL,
NULL);
Custom conversion routines are called transparently, whenever required, by ct_fetch (following a call to ct_bind specifying the conversion) and cs_convert.
Do not confuse Open Client user-defined types with Adaptive Server user-defined types. Open Client user-defined types are C-language types, declared within an application. Adaptive Server user-defined types are database column datatypes, created using the system stored procedure sp_addtype.