Oracle Tutorial

What is Oracle
SQL Keywords

Oracle Wildcards

Oracle Wildcards

Oracle Aliases

Oracle Aliases

MySQL Tutorial

MySQL Tutorial

PL/SQL Tutorial

PL/SQL Tutorial

Oracle Interview Questions

Oracle Interview Questions and Answers


Oracle Select for Update

In Oracle, the SELECT FOR UPDATE statement is used to lock the records in the cursor result set. The locks are released when the next commit or rollback statement is issued.

Oracle Select for Update Syntax

To retrieve the rows from declared cursor in Oracle, use the following syntax:

Syntax

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

Parameters:

cursor_name: The name of cursor.

select_statement: To populate the cursor result set.

column_list: The columns in the cursor result set that you wish to update.

NOWAIT: This is optional. The cursor does not wait for resources.

Oracle Select for Update example

The following Oracle example shows how to use the SELECT FOR UPDATE statement:

Example

CURSOR cur1
IS
  SELECT address, cellNo
  FROM tblCustomerLoan
  FOR UPDATE OF cellNo;

Note:

In the above example, shows how to use the SELECT FOR UPDATE statement.