Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 10.0.1 » SQL Anywhere Server - Programming » Using SQL in Applications

Block cursors Next Page

SQL Anywhere cursors

Any cursor, once opened, has an associated result set. The cursor is kept open for a length of time. During that time, the result set associated with the cursor may be changed, either through the cursor itself or, subject to isolation level requirements, by other transactions. Some cursors permit changes to the underlying data to be visible, while others do not reflect these changes. The different behavior of cursors with respect to changes to the underlying data is the sensitivity of the cursor.

SQL Anywhere provides cursors with a variety of sensitivity characteristics. This section describes what sensitivity is, and describes the sensitivity characteristics of cursors.

This section assumes that you have read What are cursors?.

Membership, order, and value changes

Changes to the underlying data can affect the result set of a cursor in the following ways:

For example, consider the following simple table with employee information (EmployeeID is the primary key column):


A cursor on the following query returns all results from the table in primary key order:

SELECT EmployeeID, Surname
FROM Employees

The membership of the result set could be changed by adding a new row or deleting a row. The values could be changed by changing one of the names in the table. The order could be changed by changing the primary key value of one of the employees.

Visible and invisible changes

Subject to isolation level requirements, the membership, order, and values of the result set of a cursor can be changed after the cursor is opened. Depending on the type of cursor in use, the result set as seen by the application may or may not change to reflect these changes.

Changes to the underlying data may be visible or invisible through the cursor. A visible change is a change that is reflected in the result set of the cursor. Changes to the underlying data that are not reflected in the result set seen by the cursor are invisible.

Cursor sensitivity overview
Cursor sensitivity example: A deleted row
Cursor sensitivity example: An updated row
Insensitive cursors
Sensitive cursors
Asensitive cursors
Value-sensitive cursors
Cursor sensitivity and performance
Cursor sensitivity and isolation levels
Requesting SQL Anywhere cursors