Preparable dynamic UPDATE statement: locating Format 2 (Update data using a preprocessable cursor)
Function
Updates a specified column in the row pointed to by the cursor in the table with a FIX specification. This statement is used when updating is to be executed by the EXECUTE statement after preprocessing by a PREPARE statement or when preprocessing and execution are to be performed in a single operation using the EXECUTE IMMEDIATE statement.
Privileges
A user who has the UPDATE privilege for a table can update the column values in that table.
Format 2: Updating rows by row in a table with a FIX specification, using a (preprocessable) cursor
UPDATE [ [authorization-identifier.]table-identifier |
Operands
For operands other than row-update-value in the SET clause and WHERE CURRENT OF GLOBAL cursor-name, and for operand rules, see UPDATE statement Format 2.
For details about the WHERE CURRENT OF GLOBAL cursor-name operand and about operand rules, see Preparable dynamic UPDATE statement: locating Format 1.
Common rules
Rules on referential constraints
Notes
Example
PREPARE GLOBAL :sel FOR 'SELECT * FROM STOCK FOR UPDATE'
Assigns CR1 to the embedded variable cr
ALLOCATE GLOBAL :cr CURSOR FOR GLOBAL :sel
PREPARE PRE1 FOR
'UPDATE SET ROW = ? WHERE CURRENT OF GLOBAL CR1'
OPEN GLOBAL :cr
FETCH GLOBAL :cr INTO Name of the variable into which columns are fetched
EXECUTE PRE1 USING :XROW
CLOSE GLOBAL :cr
DEALLOCATE PREPARE GLOBAL :sel