Using the FOR UPDATE Option
Use the FOR UPDATE option to declare an update cursor. You can use the update cursor to modify (update or delete) the current row.
In an ANSI-compliant database, you can use a Select cursor to update or delete data if the cursor was not declared with the FOR READ ONLY keywords and it follows the restrictions on update cursors that are described in Subset of SELECT statements associated with cursors. You do not need to use the FOR UPDATE keywords when you declare the cursor.
EXEC SQL declare new_curs cursor for select * from customer_notansi for update;
In an update cursor, you can update or delete rows in the active set. After you create an update cursor, you can update or delete the currently selected row by using an UPDATE or DELETE statement with the WHERE CURRENT OF clause. The words CURRENT OF refer to the row that was most recently fetched; they take the place of the usual test expressions in the WHERE clause.
An update cursor lets you perform updates that are not possible with the UPDATE statement because the decision to update and the values of the new data items can be based on the original contents of the row. Your program can evaluate or manipulate the selected data before it decides whether to update. The UPDATE statement cannot interrogate the table that is being updated.
You can specify particular columns that can be updated. The columns need not appear in the Select list of the Projection clause.