SQLSTATE Values

OpenESQL statements return database-provided SQLSTATE values as defined by the X/Open and SQL Access Group SQL CAE specification (1992). SQLSTATE is a five-character field that can be declared independently by an application, but that is also present in SQLCA, if declared. The table below lists the most common SQLSTATE values that can be returned by OpenESQL statements. For a more comprehensive list, see the documentation provide by your DBMS vendor.

The value returned in SQLSTATE consists of a two character class value followed by a three character subclass value. A class value of "01" indicates a warning and is accompanied by a SQLCODE of 1. Class values other than "01", except for the class "IM", indicate an error and are accompanied by a SQLCODE of -10000. The class "IM" is specific to warnings and errors that derive from the implementation of ODBC itself. The subclass value "000" in any class is for implementation defined conditions within the given class. The assignment of class and subclass values is defined by ANSI SQL-92.

Note: Although successful execution of a function is normally indicated by an SQLCODE of 0, the SQLSTATE 00000 also indicates success.
SQLSTATE Error
01000 General warning
01002 Disconnect error
01004 Data truncated
01006 Privilege not revoked
01S00 Invalid connection string attribute
01S01 Error in row
01S02 Option value changed
01S03 No rows updated or deleted
01S04 More than one row updated or deleted
01S05 Cancel treated as SQLFreeStmt with the SQL_CLOSE option
01S06 Attempt to fetch before the result set returned the first rowset
   
07001 Wrong number of parameters
07006 Restricted data type attribute violation
07S01 Invalid use of default parameter
   
08001 Unable to connect to data source
08002 Connection in use
08003 Connection not open
08004 Data source rejected establishment of connection
08007 Connection failure during transaction
08S01 Communication link failure
   
21S01 Insert value list does not match column list
21S02 Degree of derived table does not match column list
   
22001 String data right truncation
22002 Indicator variable required but not supplied
22003 Numeric value out of range
22005 Error in assignment
22008 Datetime field overflow
22012 Division by zero
22026 String data, length mismatch
   
23000 Integrity constraint violation
   
24000 Invalid cursor state
   
25000 Invalid transaction state
   
28000 Invalid authorization specification
   
34000 Invalid cursor name
   
37000 Syntax error or access violation
   
3C000 Duplicate cursor name
   
42000 Syntax error or access violation
   
70100 Operation aborted
   
IM001 Driver does not support this function
IM002 Data source name not found and no default driver specified
IM003 Specified driver could not be loaded
IM004 Driver's SQLAllocEnv failed
IM005 Driver's SQLAllocConnect failed
IM006 Driver's SQLSetConnect-Option failed
IM007 No data source or driver specified; dialog prohibited
IM008 Dialog failed
IM009 Unable to load translation .dll file
IM010 Data source name too long
IM011 Driver name too long
IM012 DRIVER keyword syntax error
IM013 Trace file error
   
S0001 Base table or view already exists
S0002 Base table not found
S0011 Index already exists
S0012 Index not found
S0021 Column already exists
S0022 Column not found
S0023 No default for column
   
S1000 General error
S1001 Memory allocation failure
S1002 Invalid column number
S1003 Program type out of range
S1004 SQL data type out of range
S1008 Operation canceled
S1009 Invalid argument value
S1010 Function sequence error
S1011 Operation invalid at this time
S1012 Invalid transaction operation code specified
S1015 No cursor name available
S1090 Invalid string or buffer length
S1091 Descriptor type out of range
S1092 Option type out of range
S1093 Invalid parameter number
S1095 Function type out of range
S1096 Information type out of range
S1097 Column type out of range
S1098 Scope type out of range
S1099 Nullable type out of range
S1100 Uniqueness option type out of range
S1101 Accuracy option type out of range
S1103 Direction option out of range
S1105 Invalid parameter type
S1106 Fetch type out of range
S1107 Row value out of range
S1108 Concurrency option out of range
S1109 Invalid cursor position
S1110 Invalid driver completion
S1111 Invalid bookmark value
S1C00 Driver not capable
S1T00 Timeout expired