Select employees from the table, Emp, who
1. Have a salary of Rs.10,000/- and give them an increment of 10% in salary and hence update the commission also.
2. Have a salary between Rs.5000/- and Rs.10,000/- and give them an increment of 20% in salary and hence update the commission also.
3. If the salary is less than Rs.5000/-, then give them an increment of 30% in salary and hence update the commission also.
Answer
declare
emp_row empp_a5518%rowtype;
cursor cur1 is select * from empp_a5518;
total number(9,2);
begin
open cur1;
loop
fetch cur1 into emp_row;
exit when cur1%notfound;
select emp_row.salary into total from empp_a5518 where empno=emp_row.empno;
if(total>=10000) then
update empp_a5518 set salary=salary*1.10, comm=comm*1.10 where empno=emp_row.empno;
elsif(total>=5000) then
update empp_a5518 set salary=salary*1.20, comm=comm*1.20 where empno=emp_row.empno;
else
update empp_a5518 set salary=salary*1.30, comm=comm*1.30 where empno=emp_row.empno;
end if;
end loop;
close cur1;
end;
/