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

Error 301 [Table of Contents] Error 313

Troubleshooting and Error Messages Guide

[-] Chapter 3 Error Message Writeups
[-] Query Processor Errors
[-] Error 311

Error 311



Error message text

The optimizer could not find a unique index which it could use to scan table '%.*s' for cursor '%.*s'.


For an explicit updatable cursor scan, Adaptive Server requires that a unique index exist on the table. A unique index ensures that the cursor will be positioned at the correct row the next time a fetch is performed on that cursor. Error 311 occurs when a unique index does not exist during a scan required for a cursor marked for update.


Create a unique index using one of the following methods:

If your table has one or more IDENTITY columns, you can, for future indexes you create for this table, use the database option identity in nonunique index. When this option is set, any nonunique index created on a table with an IDENTITY column will have the IDENTITY column automatically included as the last key field of the index. This allows an otherwise nonunique index to be used for a cursor marked for update.

However, all indexes would then be considered unique by the optimizer since every index that is created would be unique and this could result in poor performance for some queries. Since the identity in nonunique index option does not affect existing indexes, only future indexes you create, the existing 311 error will not be solved.


Do not use the identity in nonunique index option unless you plan to test your queries.

To use the identity in nonunique index option, the table must already have an IDENTITY column, either from a create table statement or by setting the auto identity database option to true before creating the table.

The commands to set this option are:

1> use master
2> go

1> sp_dboption database_name,
2> "identity in nonunique index", true
3> go

1> use database_name
2> go

1> checkpoint
2> go

Additional information

Refer to the ASE Reference Manual for information about create index, alter table, and sp_dboption.

Versions in which this error is raised

All versions

Error 301 [Table of Contents] Error 313