2. Embedded SQL for C : Dynamic Programming for C : The SQLVAR Array : C Variable Type Codes
 
Share this page                  
C Variable Type Codes
The type codes shown in SQLDA Structure Usage are the types that describe Ingres result fields and columns. For example, the SQL types long varchar, date, decimal and money do not describe a program variable, but rather data types that are compatible with the C types char and double. When these types are returned by the describe statement, the type code must be changed to a compatible C or SQL/C type.
The following table describes the type codes to use with C variables that will be pointed at by the sqldata pointers:
ESQL/C Type Codes (sqltype)
Length (sqllen)
C Variable Type
IISQ_INT_TYPE
1
char
IISQ_INT_TYPE
2
short
IISQ_INT_TYPE
4
int, long
IISQ_FLT_TYPE
4
float
IISQ_FLT_TYPE
8
double
IISQ_CHA_TYPE
LEN
char var[LEN +1]
IISQ_VCH_TYPE
LEN
varchar with data array [LEN]
IISQ_HDLR_TYPE
0
IISQHDLR
One-byte integer data types are specified as a char variable with no specified array dimension. Do not confuse this data type with string data types that are specified as a char variable with a fixed array dimension.
You can specify nullable data types (those variables that are associated with a null indicator) by assigning the negative of the type code to the sqltype field. If the type is negative, a null indicator must be pointed at by using the sqlind field.