Data alignment requirements

When you use SQLBindCol, SQLBindParameter, or SQLGetData, a C data type is specified for the column or parameter. On certain platforms, the storage (memory) provided for each column must be properly aligned to fetch or store a value of the specified type. The ODBC driver checks for proper data alignment. When an object is not properly aligned, the ODBC driver will issue an "Invalid string or buffer length" message (SQLSTATE HY090 or S1090).

The following table lists memory alignment requirements for processors such as Sun Sparc, Itanium-IA64, and ARM-based devices. The memory address of the data value must be a multiple of the indicated value.

C data type Alignment required
SQL_C_CHAR none
SQL_C_BINARY none
SQL_C_GUID none
SQL_C_BIT none
SQL_C_STINYINT none
SQL_C_UTINYINT none
SQL_C_TINYINT none
SQL_C_NUMERIC none
SQL_C_DEFAULT none
SQL_C_SSHORT 2
SQL_C_USHORT 2
SQL_C_SHORT 2
SQL_C_DATE 2
SQL_C_TIME 2
SQL_C_TIMESTAMP 2
SQL_C_TYPE_DATE 2
SQL_C_TYPE_TIME 2
SQL_C_TYPE_TIMESTAMP 2
SQL_C_WCHAR 2 (buffer size must be a multiple of 2 on all platforms)
SQL_C_SLONG 4
SQL_C_ULONG 4
SQL_C_LONG 4
SQL_C_FLOAT 4
SQL_C_DOUBLE 8 (4 for ARM)
SQL_C_SBIGINT 8
SQL_C_UBIGINT 8

The x86, x64, and PowerPC platforms do not require memory alignment. The x64 platform includes Advanced Micro Devices (AMD) AMD64 processors and Intel Extended Memory 64 Technology (EM64T) processors.