The DataBlade API provides the following data types to support the binary representations of integer values.
The DataBlade API supports the following data types for one-byte integer values.
DataBlade API One-Byte Integer | Description |
---|---|
mi_sint1 | Signed one-byte (eight bits) value |
mi_int1 | Unsigned one-byte (eight bits) value |
To hold unsigned one-byte integers, you can also use the mi_unsigned_char1 data type.
The DataBlade API ensures that these integer data types are one byte on all computer architectures. There is no corresponding SQL data type for one-byte integers.
Values of the mi_int1 and mi_sint1 data types can fit into an MI_DATUM structure. They can be passed by value within C user-defined routines (UDRs).
All data types, including mi_int1 and mi_sint1, must be passed by reference within client LIBMI applications.
The DataBlade API supports the following data types for two-byte integer values.
DataBlade API Two-Byte Integers | Description |
---|---|
mi_smallint | Signed two-byte integer value |
mi_unsigned_smallint | Unsigned two-byte integer value |
Use these integer data types to hold values for the SQL SMALLINT data type, which stores two-byte integer numbers that range from -32,767 to 32,767. For a description of the SQL SMALLINT data type, see the IBM Informix: Guide to SQL Reference.
The mi_smallint and mi_unsigned_smallint data types hold the internal (binary) format of a SMALLINT value. The DataBlade API ensures that the mi_smallint and mi_unsigned_smallint data types are two bytes on all computer architectures. Use these integer data types instead of the native C types (such as short int). If you access two-byte values stored in a SMALLINT in the database, but use the C short int type, conversion errors might arise if the two types are not the same size.
Values of the mi_smallint and mi_unsigned_smallint data types can fit into an MI_DATUM structure. They can be passed by value within C UDRs.
All data types, including mi_smallint and mi_unsigned_smallint, must be passed by reference within client LIBMI applications.
To transfer two-byte integers between different computer architectures, the DataBlade API provides the following functions that handle type alignment and byte order.
These DataBlade API functions are useful in the send and receive support functions of an opaque data type that contains mi_smallint values. They ensure that two-byte integer (SMALLINT) values remain consistent when transferred to and from client applications. For more information, see Conversion of Opaque-Type Data with Computer-Specific Data Types.
The DataBlade API supports the following data types for four-byte integer values.
DataBlade API Four-Byte Integers | Description |
---|---|
mi_integer | Signed four-byte integer value |
mi_unsigned_integer | Unsigned four-byte integer value |
Use these integer data types to hold values for the following SQL four-byte integer data types:
For a description of the SQL INTEGER and SERIAL data types, see the IBM Informix: Guide to SQL Reference.
The mi_integer and mi_unsigned_integer data types hold the internal (binary) format of an INTEGER or SERIAL value. The DataBlade API ensures that the mi_integer and mi_unsigned_integer data types are four bytes on all computer architectures. Use these integer data types instead of the native C types (such as int or long int). If you access four-byte values stored in a INTEGER in the database, but use the C int type, conversion errors might arise if the two types are not the same size.
Values of the mi_integer and mi_unsigned_integer data types can fit into an MI_DATUM structure. They can be passed by value within a C UDR.
All data types, including mi_integer and mi_unsigned_integer, must be passed by reference within client LIBMI applications.
To transfer four-byte integers between different computer architectures, the DataBlade API provides the following functions that handle type alignment and byte order.
The mi_get_integer( ) and mi_put_integer( ) functions are useful in the send and receive support functions of an opaque data type that contains mi_integer values. They ensure that four-byte integer (INTEGER) values remain consistent when transferred to and from client applications. For more information, see Conversion of Opaque-Type Data with Computer-Specific Data Types.
The DataBlade API supports the following data types for eight-byte integer values.
DataBlade API Eight-Byte Integers | Description |
---|---|
mi_int8 | Signed eight-byte integer value |
mi_unsigned_int8 | Unsigned eight-byte integer value |
The DataBlade API ensures that these integer data types are eight bytes on all computer architectures. Use these integer data types to hold values for the following SQL eight-byte integer data types:
For a description of the SQL INT8 and SERIAL8 data types, see the IBM Informix: Guide to SQL Reference.
The mi_int8 and mi_unsigned_int8 data types hold the internal (binary) format of an INT8 or SERIAL8 value.
Values of the mi_int8 and mi_unsigned_int8 data types cannot fit into an MI_DATUM structure. They must be passed by reference within C UDRs.
All data types, including mi_int8 and mi_unsigned_int8, must be passed by reference within client LIBMI applications.
The int8.h header file contains the following declarations for use with the INT8 data type:
The mitypes.h header file automatically includes int8.h. In turn, the milib.h header file automatically includes mitypes.h, and mi.h automatically includes milib.h. Therefore, you automatically have access to the ifx_int8_t structure, the mi_int8 data type, or any of the ESQL/C INT8-type functions when you include mi.h in your DataBlade API module.
The INT8 data type stores eight-byte integers in an Informix-proprietary internal format: the ifx_int8_t structure. This structure allows the database to store eight-byte integers in a computer-independent format.
The mi_int8 data type uses the ifx_int8_t structure to hold the binary representation of an INT8 value.
Because the binary representation of an INT8 (and mi_int8) value is an Informix-proprietary format, you cannot use standard system functions to perform integer calculations on mi_int8 values. Instead, the DataBlade API provides support for the following categories of ESQL/C functions on the INT8 data type.
Type of INT8 Function | More Information |
---|---|
Conversion functions | Converting INT8 Values |
Arithmetic-operation functions | Performing Operations on Eight-Byte Values |
Any other operations, modifications, or analyses can produce unpredictable results.
To transfer eight-byte integers between different computer architectures, the DataBlade API provides the following functions that handle type alignment and byte order.
The mi_get_int8( ) and mi_put_int8( ) functions are useful in the send and receive support function of an opaque data type that contains mi_int8 values. They ensure that eight-byte integer (INT8) values remain aligned when transferred to and from client applications. For more information, see Conversion of Opaque-Type Data with Computer-Specific Data Types.
The ESQL/C library provides the following functions that facilitate conversion of the binary representation of INT8 (mi_int8) values to and from some C-language data types.
Use the following ESQL/C library functions to perform arithmetic operations on INT8 (mi_int8) type values.
Any other operations, modifications, or analyses can produce unpredictable results.
Home | [ Top of Page | Previous Page | Next Page | Contents | Index ]