declare
cursor cemp isselect empno ,sal from emp orderby sal;
--定义参数
pempno emp.empno%type;
psal emp.sal%type;
countEmp number :=0;
salTotal number;
begin--得到工资总额的初始值selectsum(sal) into salTotal from emp;
--打开光标open cemp;
loop
-- 1.工资总额>5wexitwhen salTotal>50000;
--取一个员工涨工资fetch cemp into pempno ,psal;
--2.%notfoundexitwhen cemp%notfound;
--涨工资if salTotal+psal*1.1<50000thenupdate emp set sal = sal*1.1where empno=pempno;
--涨工资的人数
countEmp := countEmp+1;
--涨后的工资总额
salTotal := salTotal+psal*0.1;
elseexit;
endif;
end loop;
--关闭光标close cemp;
dbms_output.put_line(‘涨工资人数:‘||countEmp||‘资总额:‘||salTotal);
end;
原文:https://www.cnblogs.com/wangchuanfu/p/10988500.html
【说明】:本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:254677821)!