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.
Note
In Open SQL the update lock is set on the row directly after execution of the statement.
Syntax
<select for update statement> ::= SELECT ( ALL )? <select list> FROM <table reference> <where clause> FOR UPDATE ( OF <column reference list> )? <column reference list> ::= <column reference> ( ',' <column reference> )*.
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
Syntax
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.