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;
0 comments: