Write a PL/SQL Cursor to Hike the employee salary as following conditions If Employee salary is 0 to 1000 hike 5%. If Employee salary is 1001 to 2000 hike 25%. Other then this two conditions hike 35% of the all employees. (Display the Employee name,hiked sal as a outpu).
0
Write a PL/SQL Cursor to Hike the employee salary as following conditions
SQL>declare - If Employee salary is 0 to 1000 hike 5%.
- If Employee salary is 1001 to 2000 hike 25%.
- Other then this two conditions hike 35% of the all employees. (Display the Employee name,hiked sal as a outpu).
cursor c1 is
select empno,ename,sql
from emp
where deptno=20;
vempno emp.empno%type;
vename emp.ename%type;
vsal emp.sal%type;
begin
open c1;
loop
fetch c1 into vempno,vename,vsal;
exit when c1%notfound;
if vsal between 0 and 1000 then
vsal:=vsal+vsal*0.15;
elsif vsal between 1001 and 2000 then
vsal:=vsal+vsal*0.25;
else
vsal:=vsal+vsal*0.35;
end if;
update emp set sal=vsal
where empno=vempno;
display(rpad(vename,8)||’ ‘||vsal);
end loop;
close c1;
end;
0 comments: