Oninit Logo
The Down System Specialists
+1-913-674-0360
+44-2081-337529
Partnerships Contact
Finderr

-526 Updates are not allowed on a scroll cursor.

For a DECLARE statement, the clause FOR UPDATE is not allowed in conjunction with the SCROLL keyword. For an UPDATE statement in an ANSI-compliant database (in which the FOR UPDATE clause is not required when declaring a cursor for update), the cursor named in this statement was declared with the SCROLL keyword and may not be used for updates. The way a scroll cursor is implemented makes it unsafe for updating a table, since it will sometimes not reflect the current state of the selected rows. If you want to use a scroll cursor to examine rows and then update them, you may redesign your application in the following way (among many). Use the scroll cursor to select also the ROWID of each row. Declare a second, nonscrolling cursor that selects one row for update based on its ROWID. When it is time to update a selected row:

* Open the update cursor using the ROWID value found by the scrolling cursor.

* Fetch the row, and check the error code (the row might have been deleted).

* If the fetch succeeded, verify that the row contents are unchanged from those selected by the scrolling cursor (the row is now locked, so it cannot change further, but it might have changed between the two fetches).

* If the row is unchanged, update it using the nonscrolling cursor.

* Close the nonscrolling cursor.

* This procedure ensures that the update reflects the current state of the table but also retains the convenience of the scrolling cursor. A fetch by ROWID of a recently fetched row will usually entail no disk activity and so will not cost much time.