2. Embedded SQL for C : C Variables and Data Types : Data Type Conversion
 
Share this page                  
Data Type Conversion
A C variable declaration must be compatible with the Ingres value it represents. Numeric Ingres values can be set by and retrieved into numeric variables, and Ingres character values can be set by and retrieved into character variables.
Data type conversion occurs automatically for different numeric types such as from floating-point database column values into integer C variables, and for character strings, such as from varying-length Ingres character fields into fixed-length C character string buffers.
Ingres does not automatically convert between numeric and character types. You must use the Ingres type conversion operators, the Ingres ascii function, or a C conversion routine for this purpose.
The following table shows the default type compatibility for each Ingres data type.
Ingres Type
C Type
char(N)
char [N+1]
varchar(N)
char [N+1]
char(N)(with embedded nulls)
varchar
varchar(N)(with embedded nulls)
varchar
integer1
short
integer2
short
smallint
short
integer
int
integer
long
float4
float
bigint
long (64-bit); long long (32-bit)
float
double
date or ingresdate
char [26]
ansidate
char [11]
time without time zone
char [22]
time with time zone
char [32]
time with local time zone
char [32]
timestamp without time zone
char [40]
timestamp with time zone
char [50]
timestamp with local time zone
char [50]
interval year to month
char [16]
interval day to second
char [46]
money
double
table_key
char[8 ]
object_key
char[16]
decimal
double
long varchar
char[ ]
long varchar (with embedded nulls)
char[ ]
byte
char[ ]
varbyte
char[ ]
long byte
char[ ]
nchar(N)
wchar_t[N+1]
nvarchar(N)
wchar_t[N+1]
long nvarchar (with embedded nulls)
nvarchar