Write a PL/SQL Cursor to Hike the employee salary following conditions. i.If Employee job is ‘CLERK’ hike the salary 100. ii.If Employee job is ‘SALESMAN’ hike the salary 200. iii.Other then the this two conditions hike the salary 300. (Display the output as employee name, job and updated salary).
0
Write a PL/SQL Cursor to Hike the employee salary following conditions.
i.If Employee job is ‘CLERK’ hike the salary 100.
ii.If Employee job is ‘SALESMAN’ hike the salary 200.
iii.Other then the this two conditions hike the salary 300. (Display the output as employee name, job and updated salary).
SQL>DECLARE
cursor jc is
select empno,ename,job,sal
from emp;
i emp%rowtype;
BEGIN
open jc;
loop
fetch jc into i.empno,i.ename,i.job,i.sal;
exit when jc%notfound;
if i.job=’CLERK’ then
i.sal:=i.sal+100;
elsif i.job=’SALESMAN’ then
i.sal:=i.sal+200;
else
i.sal:=i.sal+300;
end if;
update emp set sal:=i.sal
where empno=i.empno;
display(rpad(i.ename,8)||’ ‘||rpad(i.job,10)||’ ‘||i.sal);
end loop;
close jc;
END;
i.If Employee job is ‘CLERK’ hike the salary 100.
ii.If Employee job is ‘SALESMAN’ hike the salary 200.
iii.Other then the this two conditions hike the salary 300. (Display the output as employee name, job and updated salary).
SQL>DECLARE
cursor jc is
select empno,ename,job,sal
from emp;
i emp%rowtype;
BEGIN
open jc;
loop
fetch jc into i.empno,i.ename,i.job,i.sal;
exit when jc%notfound;
if i.job=’CLERK’ then
i.sal:=i.sal+100;
elsif i.job=’SALESMAN’ then
i.sal:=i.sal+200;
else
i.sal:=i.sal+300;
end if;
update emp set sal:=i.sal
where empno=i.empno;
display(rpad(i.ename,8)||’ ‘||rpad(i.job,10)||’ ‘||i.sal);
end loop;
close jc;
END;
0 comments: