Use of "for update of" in Oracle Cursor

          

Oracle - use of "for update of"

Next>>         Oracle Tutorial
Oracle - Describe the use of "for update of" in Oracle Cursor. - April 30, 2009 at 20:00 PM by Amit Satpute

Describe the use of "for update of" in Oracle Cursor.

The CURSOR FOR UPDATE obtains a lock on a selected number of rows that have not undergone a COMMIT yet, until a user is done with the transaction.

SQL> declare
2 cursor cur_emp is
3 select id
4 from emp
5 for update of dept;
6 begin
7 for r_cur_emp in cur_emp loop
8 if r_ cur_emp.dept = 'IT' then
9 update emp
10 set salary = salary + 1000
11 where current of cur_emp;
12 end if;
13 end loop;
14 end;
15 /

In this example, we are increasing the salary of the employees from the IT department by 1000 each.


Next>>

Also read

Oracle DCL and TCL

Oracle DML commands

Oracle error handling

Oracle functions

Oracle function, procedure, package



Write your comment - Share Knowledge and Experience


 

 
Interview questions
Latest MCQs
» General awareness - Banking » ASP.NET » PL/SQL » Mechanical Engineering
» IAS Prelims GS » Java » Programming Language » Electrical Engineering
» English » C++ » Software Engineering » Electronic Engineering
» Quantitative Aptitude » Oracle » English » Finance
Home | About us | Sitemap | Contact us | We are hiring