![]() | ![]() |
Home |
|
|
Reference Manual Volumes 1 - 4 (Online Only) |
|
| Chapter 6 SQLSTATE Codes and Messages |
Chapter 6
This chapter describes Adaptive Server's SQLSTATE status codes and their associated messages.
SQLSTATE codes are required for entry level SQL92 compliance. They provide diagnostic information about two types of conditions:
Warnings - conditions that require user notification but are not serious enough to prevent a SQL statement from executing successfully
Exceptions - conditions that prevent a SQL statement from having any effect on the database
Each SQLSTATE code consists of a 2-character class followed by a 3-character subclass. The class specifies general information about error type. The subclass specifies more specific information.
SQLSTATE codes are stored in the sysmessages system table, along with the messages that display when these conditions are detected. Not all Adaptive Server error conditions are associated with a SQLSTATE code--only those mandated by SQL92. In some cases, multiple Adaptive Server error conditions are associated with a single SQLSTATE value.
Adaptive Server currently detects only one SQLSTATE warning condition, which is described in Table 6-1:
Message | Value | Description |
Warning - null value eliminated in set function. | 01003 | Occurs when you use an aggregate function (avg, max, min, sum, or count) on an expression with a null value. |
Warning-string data, right truncation | 01004 | Occurs when character, unichar, or binary data is truncated to 255 bytes. The data may be:
|
Adaptive Server detects the following types of exceptions:
Cardinality violations
Data exceptions
Integrity constraint violations
Invalid cursor states
Syntax errors and access rule violations
Transaction rollbacks
with check option violations
Exception conditions are described in Table 6-2 through Table 6-8. Each class of exceptions appears in its own table. Within each table, conditions are sorted alphabetically by message text.
Cardinality violations occur when a query that should return only a single row returns more than one row to an Embedded SQL(TM) application.
Message | Value | Description |
Subquery returned more than 1 value. This is illegal when the subquery follows =, !=, <, <=, >, >=. or when the subquery is used as an expression. | 21000 | Occurs when:
|
Data exceptions occur when an entry:
Is too long for its datatype,
Contains an illegal escape sequence, or
Contains other format errors.
Message | Value | Description |
Arithmetic overflow occurred. | 22003 | Occurs when:
|
Data exception - string data right truncated. | 22001 | Occurs when a char, unichar, univarchar, or varchar column is too short for the data being inserted or updated and non-blank characters must be truncated. |
Divide by zero occurred. | 22012 | Occurs when a numeric expression is being evaluated and the value of the divisor is zero. |
Illegal escape character found. There are fewer bytes than necessary to form a valid character. | 22019 | Occurs when you are searching for strings that match a given pattern if the escape sequence does not consist of a single character. |
Invalid pattern string. The character following the escape character must be percent sign, underscore, left square bracket, right square bracket, or the escape character. | 22025 | Occurs when you are searching for strings that match a particular pattern when:
|
Integrity constraint violations occur when an insert, update, or delete statement violates a primary key, foreign key, check, or unique constraint or a unique index.
Message | Value | Description |
Attempt to insert duplicate key row in object object_name with unique index index_name | 23000 | Occurs when a duplicate row is inserted into a table that has a unique constraint or index. |
Check constraint violation occurred, dbname = database_name, table name = table_name, constraint name = constraint_name | 23000 | Occurs when an update or delete would violate a check constraint on a column. |
Dependent foreign key constraint violation in a referential integrity constraint. dbname = database_name, table name = table_name, constraint name = constraint_name | 23000 | Occurs when an update or delete on a primary key table would violate a foreign key constraint. |
Foreign key constraint violation occurred, dbname = database_name, table name = table_name, constraint name = constraint_name | 23000 | Occurs when an insert or update on a foreign key table is performed without a matching value in the primary key table. |
Invalid cursor states occur when:
A fetch uses a cursor that is not currently open, or
An update where current of or delete where current of affects a cursor row that has been modified or deleted, or
An update where current of or delete where current of affects a cursor row that not been fetched.
Message | Value | Description |
Attempt to use cursor cursor_name which is not open. Use the system stored procedure sp_cursorinfo for more information. | 24000 | Occurs when an attempt is made to fetch from a cursor that has never been opened or that was closed by a commit statement or an implicit or explicit rollback. Reopen the cursor and repeat the fetch. |
Cursor cursor_name was closed implicitly because the current cursor position was deleted due to an update or a delete. The cursor scan position could not be recovered. This happens for cursors which reference more than one table. | 24000 | Occurs when the join column of a multitable cursor has been deleted or changed. Issue another fetch to reposition the cursor. |
The cursor cursor_name had its current scan position deleted because of a DELETE/UPDATE WHERE CURRENT OF or a regular searched DELETE/UPDATE. You must do a new FETCH before doing an UPDATE or DELETE WHERE CURRENT OF. | 24000 | Occurs when a user issues an update/delete where current of whose current cursor position has been deleted or changed. Issue another fetch before retrying the update/delete where current of. |
The UPDATE/DELETE WHERE CURRENT OF failed for the cursor cursor_name because it is not positioned on a row. | 24000 | Occurs when a user issues an update/delete where current of on a cursor that:
|
Syntax errors are generated by SQL statements that contain unterminated comments, implicit datatype conversions not supported by Adaptive Server or other incorrect syntax.
Access rule violations are generated when a user tries to access an object that does not exist or one for which he or she does not have the correct permissions.
Message | Value | Description |
command permission denied on object object_name, database database_name, owner owner_name . | 42000 | Occurs when a user tries to access an object for which he or she does not have the proper permissions. |
Implicit conversion from datatype 'datatype' to 'datatype' is not allowed. Use the CONVERT function to run this query. | 42000 | Occurs when the user attempts to convert one datatype to another but Adaptive Server cannot do the conversion implicitly. |
Incorrect syntax near object_name. | 42000 | Occurs when incorrect SQL syntax is found near the object specified. |
Insert error: column name or number of supplied values does not match table definition. | 42000 | Occurs during inserts when an invalid column name is used or when an incorrect number of values is inserted. |
Missing end comment mark '*/'. | 42000 | Occurs when a comment that begins with the /* opening delimiter does not also have the */ closing delimiter. |
object_name not found. Specify owner.objectname or use sp_help to check whether the object exists (sp_help may produce lots of output). | 42000 | Occurs when a user tries to reference an object that he or she does not own. When referencing an object owned by another user, be sure to qualify the object name with the name of its owner. |
The size (size) given to the object_name exceeds the maximum. The largest size allowed is size. | 42000 | Occurs when:
|
Transaction rollbacks occur when the transaction isolation level is set to 3, but Adaptive Server cannot guarantee that concurrent transactions can be serialized. This type of exception generally results from system problems such as disk crashes and offline disks.
Message | Value | Description |
Your server command (process id #process_id ) was deadlocked with another process and has been chosen as deadlock victim. Re-run your command. | 40001 | Occurs when Adaptive Server detects that it cannot guarantee that two or more concurrent transactions can be serialized. |
This class of exception occurs when data being inserted or updated through a view would not be visible through the view.
Message | Value | Description |
The attempted insert or update failed because the target view was either created WITH CHECK OPTION or spans another view created WITH CHECK OPTION. At least one resultant row from the command would not qualify under the CHECK OPTION constraint. | 44000 | Occurs when a view, or any view on which it depends, was created with a with check option clause. |
|
|