While defining DB2 driver in /etc/odbcinst.ini file use:
# Driver for DN2 [DB2] Description = ODBC for DB2 Driver64 = /home/opt/ibm/db2/V10.1/lib64/libdb2o.soPay attention to letter o after libdb2. If you omit it the whole stuff seemingly works with only one exception: NULL values in the result set are not recognized.
libdb2.so is "CLI DB2 driver" and "libdbo.so" is "ODBC driver". The main difference is handling SQLLEN data type. On 64 bit Linux DB2/CLI uses 32 bit but unixODBC and libdb2o.so use 64 bit. It mean that the code below does not work as expected if compiled with ODBC header and run against libdb2.so. libdb2.so return 32 bit -1 but ODBC code compares it with -1 64 bit. :
SQLRETURN ret; SQLLEN cbData = 0; ret = SQLGetData(cur->hstmt, (SQLUSMALLINT)(iCol+1), nTargetType, buffer.GetBuffer(), buffer.GetRemaining(), &cbData); if (cbData == SQL_NULL_DATA) { // expected NULL value }
Brak komentarzy:
Prześlij komentarz