Easysoft

ODBC 2.x to ODBC 3.x SQLSTATE Mappings

In ODBC 3.x, HYxxx SQLSTATEs are returned instead of S1xxx, and 42Sxx SQLSTATEs are returned instead of S00XX. This was done to align with X/Open and ISO standards. In many cases, the mapping is not one-to-one because the standards have redefined the interpretation of several SQLSTATEs.

When an ODBC 2.x application is upgraded to an ODBC 3.x application, the application has to be changed to expect ODBC 3.x SQLSTATEs instead of ODBC 2.x SQLSTATEs. The following table lists the ODBC 3.x SQLSTATEs that each ODBC 2.x SQLSTATE is mapped to.

When the SQL_ATTR_ODBC_VERSION environment attribute is set to SQL_OV_ODBC2, the driver posts ODBC 2.x SQLSTATEs instead of ODBC 3.x SQLSTATEs when SQLGetDiagField or SQLGetDiagRec is called. A specific mapping can be determined by noting the ODBC 2.x SQLSTATE in column 1 of the following table that corresponds to the ODBC 3.x SQLSTATE in column 2.

ODBC 2.x SQLSTATEODBC 3.x SQLSTATEComments
01S0301001
01S0401001
22003HY019
2200822007
2200522018
2400007005
3700042000
70100HY018
S000142S01
S000242S02
S001142S11
S001242S12
S002142S21
S002242S22
S002342S23
S1000HY000
S1001HY001
S100207009ODBC 2.x SQLSTATE S1002 is mapped to ODBC 3.x; SQLSTATE 07009 if the underlying function is SQLBindCol, SQLColAttribute, SQLExtendedFetch, SQLFetch, SQLFetchScroll, or SQLGetData.
S1003HY003
S1004HY004
S1008HY008
S1009HY009Returned for an invalid use of a null pointer.
S1009HY024Returned for an invalid attribute value.
S1009HY092Returned for updating or deleting data by a call to SQLSetPos, or adding, updating, or deleting data by a call to SQLBulkOperations, when the concurrency is read-only.
S1010HY007
HY010
SQLSTATE S1010 is mapped to SQLSTATE HY007 when SQLDescribeCol is called prior to calling SQLPrepare, SQLExecDirect, or a catalog function for the <StatementHandle>. Otherwise, SQLSTATE S1010 is mapped to SQLSTATE HY010.
S1011HY011
S1012HY012
S1090HY090
S1091HY091
S1092HY092
S109307009ODBC 3.x SQLSTATE 07009 is mapped to ODBC 2.x SQLSTATE S1093 if the underlying function is SQLBindParameter or SQLDescribeParam.
S1096HY096
S1097HY097
S1098HY098
S1099HY099
S1100HY100
S1101HY101
S1103HY103
S1104HY104
S1105HY105
S1106HY106
S1107HY107
S1108HY108
S1109HY109
S1110HY110
S1111HY111
S1C00HYC00
S1T00HYT00

Note ODBC 3.x SQLSTATE 07008 is mapped to ODBC 2.x SQLSTATE S1000.



© 1993 - 2012 Easysoft Limited. All rights reserved.