The SELECT … FOR UPDATE statement retrieves columns from a uniquely specified row of database table and simultaneously set an update lock on the selected row. This statement is specific to Open SQL.
In Open SQL the update lock is set on the row directly after execution of the statement.
<select for update statement>
::= |
Some semantic restrictions apply:
● the FROM clause can contain only a single table
● for all primary key columns of the table, the WHERE clause must contain <comparison predicate> with the comparison operator '='; all these comparison predicates must be combined by AND
● the SELECT list must not contain set functions
SELECT employee_name FROM employees WHERE employee_id = 123 FOR UPDATE |
Example 1: The SELECT FOR UPDATE Statement. From the table employees a single row with the key value employee_id = 123 is selected. Simultaneously, an update lock is set on the selected row.