This Oracle tutorial explains how to use the Oracle/PLSQL SELECT FOR UPDATE statement with syntax and examples.
The SELECT FOR UPDATE statement allows you to lock the records in the cursor result set. You are not required to make changes to the records in order to use this statement. The record locks are released when the next commit or rollback statement is issued.
The syntax for the SELECT FOR UPDATE statement in Oracle/PLSQL is:
FOR UPDATE [OF column_list] [NOWAIT];
Parameters or Arguments
The name of the cursor.
A SELECT statement that will populate your cursor result set.
The columns in the cursor result set that you wish to update.
Optional. The cursor does not wait for resources.
For example, you could use the SELECT FOR UPDATE statement as follows:
SELECT course_number, instructor
FOR UPDATE OF instructor;
If you plan on updating or deleting records that have been referenced by a SELECT FOR UPDATE statement, you can use the WHERE CURRENT OF statement.