Home Privacy Policy Feedback Link to us Site Map

Oracle/PLSQL: SELECT FOR UPDATE Statement


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 is:

CURSOR cursor_name
IS
   select_statement
   FOR UPDATE [of column_list] [NOWAIT];


For example, you could use the Select For Update statement as follows:

CURSOR c1
IS
   SELECT course_number, instructor
   from courses_tbl
   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.