Oracle面试题

为员工涨工资,从最低工资调起,每人涨10%,但是工资总额不超过5万元
请计算长工资的人数和长工资后的工资总额,并输出长工资人数及工资总额set serveroutput on
declare
cursor cemp is select empno,sal from emp order by sal;
pempno emp.empno%type;
psal emp.sal%type;

countEmp number :=0;
salTotal number;
begin
select sum(sal) into salTotal from emp;
open cemp;
loop
exit when salTotal >150000;
fetch cemp into pempno,psal;
exit when cemp%notfound;
if (salTotal+psal*0.1)<=150000 then
update emp set sal=sal*1.1 where empno=pempno;
countEmp := countEmp +1;

salTotal := salTotal +psal*0.1;
end if;
end loop;
close cemp;
commit;
dbms_output.put_line('人数:'||countEmp ||' 涨后的工资总额:'||salTotal);
end;
/
已标记关键词 清除标记
相关推荐
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页