ODBC 64-bit Windows and Linux Considerations
Identify header files and data types when using the ODBC driver in an IBM® i Access environment.
The IBM i Access
ODBC driver implements support for 64-bit ODBC APIs. In general, the
support is implemented as defined in the ODBC header files that are
provided by Microsoft for Windows environments and unixODBC
for Linux environments. When
you write code to call the ODBC APIs, refer to the appropriate ODBC
header file for the function prototype. The header files are as follows:
- sql.h
- sqlext.h
- sqltypes.h
- sqlucode.h
Inherent differences between Windows, Linux,
and 64-bit include the following:
- In 64-bit Linux environments, the size of a long C/C++ type is 8 bytes. In other environments, including 64-bit Windows, the size of the long type is 4 bytes.
- In 32-bit environments, the size of a pointer is 4 bytes. In 64-bit environments, the size of a pointer is 8 bytes.
- Some of the ODBC APIs have parameters that are pointers. In some cases, these pointers are used to pass data of different sizes between the application and the driver. In 64-bit implementations, there are some changes where the size of data passed this way was changed from being 4-byte values to 8-byte values.
Some common C/C++ types and the size of each are listed in the following table.
C/C++ Type | Linux 64-bit | Windows 64-bit | Linux 32-bit | Windows 32-bit |
---|---|---|---|---|
int | 4 | 4 | 4 | 4 |
long | 8 | 4 | 4 | 4 |
long long | 8 | Not defined | 8 | Not defined |
LONG LONG | Not defined | 8 | Not defined | Not defined |
pointer size | 8 | 8 | 4 | 4 |
INT32 | Not defined 41 | 4 | Not defined 41 | 4 |
INT64 | Not defined 81 | 8 | Not defined 81 | 8 |
SQLSMALLINT | 2 | 2 | 2 | 2 |
SQLINTEGER | 4 | 4 | 4 | 4 |
SQLLEN | 8 | 8 | 4 | 4 |
SQLSETPOSIROW | 8 | 8 | 2 | 2 |
SQLROWCOUNT | 8 | Not defined | 4 | 4 |
SQLROWSETSIZE | 4 | Not defined | 4 | 4 |
SQLROWOFFSET | 8 | Not defined | 4 | 4 |
SQLPOINTER | 8 | 8 | 4 | 4 |
UINT_PTR | Not defined 81 | 8 | Not defined 41 | 4 |
DWORD | Not defined 41 | 4 | Not defined 41 | 4 |
SDWORD | Not defined 41 | 4 | Not defined 41 | 4 |
ULONG_PTR | Not defined 81 | 8 | Not defined 41 | 4 |
SQLHANDLE | 8 | 8 | 4 | 4 |
SQLHDESC | 8 | 8 | 4 | 4 |
Note: 1. This type is not defined in a standard
header file. It is defined in the toolkit that is provided with the Linux Application
Package product.
Options for the ODBC APIs listed below result in different behavior by the 32-bit and 64-bit ODBC drivers for parameter pointer data. Generally, the 64-bit ODBC drivers treat parameter pointer data as 8 byte (64-bit) values, unless otherwise noted.
- SQLGetConnectAttr
- SQL_ATTR_QUIET_MODE
- SQLGetConnectOption (This API is mapped to SQLGetConnectAttr by the ODBC driver manager.)
- SQL_ATTR_QUIET_MODE
- SQLGetDescField
- SQL_DESC_ARRAY_SIZE
- SQLGetDiagField
- SQL_DIAG_CURSOR_ROW_COUNT
- SQLGetInfo (These options are all handled by the ODBC driver manager.)
- SQL_DRIVER_HENV
- SQLGetStmtAttr
- SQL_ATTR_APP_PARAM_DESC
- SQLGetStmtOption (This API is mapped to SQLGetStmtAttr by the ODBC driver manager.)
- SQL_MAX_LENGTH
- SQLSetConnectAttr
- SQL_ATTR_QUIET_MODE
- SQLSetConnectOption (This API is mapped to SQLSetConnectAttr by the ODBC driver manager.)
- SQL_ATTR_QUIET_MODE
- SQLSetDescField
- SQL_DESC_ARRAY_SIZE
- SQLSetStmtAttr
- SQL_ATTR_APP_PARAM_DESC
- SQLSetConnectAttr
- SQL_MAX_LENGTH