5. Working with Embedded SQL : Data Manipulation with Cursors : Using Cursors to Update Data
 
Share this page                  
Using Cursors to Update Data
To use a cursor to update rows, specify the FOR UPDATE clause when declaring the cursor:
EXEC SQL DECLARE cursor_name CURSOR FOR
         select_statement
         FOR [DEFERRED | DIRECT] UPDATE FROM column {, column};
The FOR UPDATE clause must list any columns in the selected database table that are intended to be updated. Columns cannot be updated unless they have been declared for update. To delete rows, the cursor does not need to be declared for update.
The cursor UPDATE statement has the following syntax:
EXEC SQL UPDATE tablename
         SET column = expression {, column = expression}
         WHERE CURRENT OF cursor_name;