declare
cursor cemp is
select empno, sal from emp;
cempno emp.empno%type;
csal emp.sal%type;
empcount number := 0;
totalsal number;
begin
open cemp;
select sum(sal) into totalsal from emp;
loop
fetch cemp
into cempno, csal;
--判断涨后工资是否超过5万
exit when totalsal + csal * 0.1> 50000;
update emp set sal = sal + sal * 0.1 where empno = cempno;
exit when cemp%notfound;
empcount := empcount + 1;
--涨后工资总额
totalsal := totalsal + csal * 0.1;
end loop;
close cemp;
dbms_output.put_line('涨工资人数: ' || empcount || ' 总工资: ' || totalsal);
end;