Free Web Hosting by Netfirms
Web Hosting by Netfirms | Free Domain Names by Netfirms

AmZone

A m Z o n e


The secret of FOR UPDATE OF clause

We specify the column names that would be updated in a cursor with the "FOR UPDATE OF" clause. Does this mean that Oracle carries out column level locking, or is there some other process triggered for the mentioned column(s)?


cursor cr_emp is select empno, ename, job, sal from emp where deptno = 'SOFTWARE' for update of sal; -- what is the importance of putting column name over here?


  1. For multiple tables in the cursor, the columns in the 'FOR UPDATE OF' clause specify which tables' rows are going to be locked. Omitting this clause will lock the selected rows from all the tables in the query.
  2. For a single table in the cursor, the columns in the 'FOR UPDATE OF' clause are not significant.
Specifying the column name is a good programming practice, since it points out what column is intended to be updated later in the code. Moreover, this would reduce the impact in case oracle decides to make this mandatory in future releases, or enhances this option.


Press the Back button of you Browser to go to previous page
Home