Show TOC Start of Content Area

This graphic is explained in the accompanying text SELECT FOR UPDATE Statement  Locate the document in its SAP Library structure

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

This graphic is explained in the accompanying text

<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

Example

This graphic is explained in the accompanying text

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.

More Information

Select List

Table Reference

WHERE Clause

Column Reference

End of Content Area