title: Difference between FOR UPDATE OF and FOR UPDATE
body: <p>What makes difference, when I use <code>FOR UPDATE OF SAL</code> or simply write <code>FOR UPDATE</code>.</p>
  
  <p>According to <a href="http://docstore.mik.ua/orelly/oracle/prog2/ch06_11.htm" rel="noreferrer">O'Reilly</a></p>
  
  <blockquote>
    <p>The OF list of the FOR UPDATE clause does not restrict you to changing
    only those columns listed. Locks are still placed on all rows; the OF
    list just gives you a way to document more clearly what you intend to
    change. If you simply state FOR UPDATE in the query and do not include
    one or more columns after the OF keyword, then the database will then
    lock all identified rows across all tables listed in the FROM clause.</p>
  </blockquote>
  
  <p>Which means, when I specify column name with <code>FOR UPDATE OF SAL</code>, other user can make change with <code>SAL</code> column only. But, practically, this is not the case. I'm still getting lock in other session. Can anyone explain the difference.</p>
  
  <p><strong>UPDATE</strong></p>
  
  <pre><code> ----- SESSION 1
  
  declare
   emp_info emp.ename%type;
   cursor emp_cur is select ename from emp join dept using(deptno) where deptno=&amp;no for update of sal;
   begin
   open emp_cur;
   loop
   fetch emp_cur into emp_info;
   exit when emp_cur%notfound;
   dbms_output.put_line(emp_info);
   end loop;
   close emp_cur;
   end;
  
    ----- SESSION 2
  
    update emp set comm=5 where deptno=10;
    ---- hanged/waiting in session 2
  </code></pre>