Updating previously retrieved data
To scroll backward through data and update it, use a scrollable cursor that is declared with the FOR UPDATE clause.
About this task
Procedure
To update previously retrieved data, use these steps:
- Declare the cursor with the SENSITIVE STATIC SCROLL keywords.
- Open the cursor.
- Issue a FETCH statement to position the cursor at the end of the result table.
- Issue FETCH statements to move the cursor backward to the row that you want to update.
- Specify the WHERE CURRENT OF clause in the UPDATE or DELETE statement that updates the current row.
- Repeat steps 4 and 5 until all required rows are updated.
- When you have retrieved and updated all the data, close the cursor.