Sybase Technical Library - Product Manuals Home
[Search Forms] [Previous Section with Hits] [Next Section with Hits] [Clear Search] Expand Search

Chapter 5 Reserved Words [Table of Contents] Chapter 7 Commands

Reference Manual Volumes 1 - 4 (Online Only)

[-] Chapter 6 SQLSTATE Codes and Messages

Chapter 6

SQLSTATE Codes and Messages

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:

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.

Warnings

Adaptive Server currently detects only one SQLSTATE warning condition, which is described in Table 6-1:

SQLSTATE warnings

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:

  • The result of a select statement in which the client does not support the WIDE TABLES property.

  • Parameters to an RPC on remote Adaptive Servers or Open Servers that do not support the WIDE TABLES property.

Exceptions

Adaptive Server detects the following types of exceptions:

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

Cardinality violations occur when a query that should return only a single row returns more than one row to an Embedded SQL(TM) application.

Cardinality violations

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:

  • A scalar subquery or a row subquery returns more than one row.

  • A select into parameter_list query in Embedded SQL returns more than one row.

Data exceptions

Data exceptions occur when an entry:

Integrity constraint violations

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.

Integrity constraint violations

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

Invalid cursor states occur when:

Syntax errors and access rule violations

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.

Syntax errors and access rule violations

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:

  • The total size of all the columns in a table definition exceeds the maximum allowed row size.

  • The size of a single column or parameter exceeds the maximum allowed for its datatype.

Transaction rollbacks

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.

Transaction rollbacks

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.

with check option violation

This class of exception occurs when data being inserted or updated through a view would not be visible through the view.

with check option violation

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.


Chapter 5 Reserved Words [Table of Contents] Chapter 7 Commands