In order to transfer information between a program and the database engine, every piece of data must have a data type. The Embedded SQL data type constants (prefixed with DT_) can be found in the SQLDEF.H header file (see "SQLDEF.H header file"). You can create a host variable (next section) of any one of the supported types. You can also use these types in an SQLDA structure for passing data to and from the database.
The following data types are supported by the Embedded SQL programming interface:
typedef struct DECIMAL {
char array[1];
} DECIMAL;
typedef struct VARCHAR {
unsigned short int len;
char array[1];
} VARCHAR;
typedef struct BINARY {
unsigned short int len;
char array[1];
} BINARY;
typedef struct sqldatetime {
unsigned short year; /* e.g. 1992 */
unsigned char month; /* 0-11 */
unsigned char day_of_week; /* 0-6 0=Sunday */
unsigned short day_of_year; /* 0-365 */
unsigned char day; /* 1-31 */
unsigned char hour; /* 0-23 */
unsigned char minute; /* 0-59 */
unsigned char second; /* 0-59 */
unsigned long microsecond; /* 0-999999 */
} SQLDATETIME;
The SQLDATETIME struct can be used to retrieve fields of DATE, TIME, and TIMESTAMP type (or anything that can be converted to one of these). Often, applications have their own formats and date manipulation code. Fetching data in this structure makes it easier for a programmer to manipulate this data. Note that DATE, TIME and TIMESTAMP fields can also be fetched and updated with any character type. See the DATE_FORMAT, TIME_FORMAT, TIMESTAMP_FORMAT, and DATE_ORDER database options in "SET OPTION statement".
The structures are defined in the SQLCA.H file. The VARCHAR, BINARY and DECIMAL types contain a one-character array and are thus not useful for declaring host variables but they are useful for allocating variables dynamically or typecasting other variables.
There are no corresponding Embedded SQL interface data types for the various DATE and TIME database types. These database types are all fetched and updated using either the SQLDATETIME structure or character strings.
There are no Embedded SQL interface data types for LONG VARCHAR and LONG BINARY database types. These database types are fetched and updated in pieces. For more information see "GET DATA statement" and "SET statement".