Write a PL/SQL Program to display the employee details and any employees work in 50 department remove that employees and display the removing employees with locking system.

0
Write a PL/SQL Program to display the employee details and any employees work in 50 department remove that employees and display the removing employees with locking system.

SQL>DECLARE
          cursor lc is
          select ename,sal deptno
          from emp
          for update;
          i lc%rowtype;
          BEGIN
          display(‘The emp det are’);
          display(‘EmpName’||’ ‘||’Salary’||’ ‘||’DeptNum’);
          display(‘-------‘||’  ‘||’--------‘||’ ‘||’-------‘);
          open lc;
          loop
          fetch lc into I;
          exit when lc%notfound;
          display(rpad(i.ename,8)||’ ‘||rpad(i.sal,5)||’ ‘||i.deptno);
          if i.deptno=50 then
          delete from emp
          where current of lc;
          end if;
          end loop;
          close lc;
          display(‘After delete the 50th dept emps’);
          open lc;
          loop
          fetch lc into I;
          exit when lc%notfound;
          display(rpad(i.ename,8)||’ ‘||rpad(i.sal,5)||’ ‘||i.deptno);
          end loop;
          close lc;
          end;

 Click here to go to Back page

About the author

Donec non enim in turpis pulvinar facilisis. Ut felis. Praesent dapibus, neque id cursus faucibus. Aenean fermentum, eget tincidunt.

0 comments:

Recent Posts