![]() |
|
The database server supports the following data types for integer values.
The C language supports the short int and long int data types for integers. The size of these C integer data types depends on the hardware and operating system of the computer you use. For example, a long data type could be 4 bytes long on a 32-bit platform but 8 bytes long on a 64-bit platform.
Therefore, when you declare an integer host variable, you must ensure that this host variable is large enough for all possible values of the SQL integer data type with which the variable is associated. For more information about how to implement integer data types on your system, check with your system administrator or your C documentation.
Informix provides the following data types for specifying integer host variables of specific lengths.
Warning: The preceding integer data types are reserved. Your programs must not use typedef or $typedef statements to define these data types.
The integer host variable data types are defined in the ifxtypes.h file, which is automatically included in your program when you compile it with the esql script.
Important: Many of the INFORMIX-ESQL/C library functions have been changed to declare the Informix integer data types rather than the machine specific types such as int, short, and long. Informix recommends that you use the Informix integer types when you call ESQL/C library functions.
The INT8 and SERIAL8 SQL Data Types
ESQL/C supports the SQL INT8 and SERIAL8 data types with the int8 data type. The int8 data type is a machine-independent method that represents numbers in the range -(263 -1) to 263-1.
For a complete description of the INT8 and SERIAL8 SQL data types, see the Informix Guide to SQL: Reference. This section describes how to manipulate the ESQL/C data type, int8.
Use the ESQL/C int8 data type to declare host variables for database values of type INT8 and SERIAL8. Figure 5-1 shows the fields of the structure ifx_int8_t, which represents an INT8 or SERIAL8 value.
Figure 5-1
The int8.h header file contains the ifx_int8 structure and a typedef called ifx_int8_t. Include this file in all C source files that use any int8 host variables as shown in the following example:
You can declare an int8 host variable in either of the following ways:
You must perform all operations on int8 type numbers through the ESQL/C library functions for the int8 data type. Any other operations, modifications, or analyses can produce unpredictable results. The ESQL/C library provides functions that allow you to manipulate int8 numbers and convert int8 type numbers to and from other data types. The following table describes these functions.
For information on the syntax and behavior of these library functions, refer to Appendix B, ESQL/C Function Library.