为了账号安全,请及时绑定邮箱和手机立即绑定

根据老师的结果为什么要手动执行几次循环?有没有什么办法让程序自动重复执行

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;


正在回答

举报

0/150
提交
取消

根据老师的结果为什么要手动执行几次循环?有没有什么办法让程序自动重复执行

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信