emp表中对所有雇员按他们基本薪水的10%给他们加薪, -- 如果所增加后的薪水大于5000,则取消加薪。


declare
  cursor s3 is
    select * from emp;
  v_res emp%rowtype;
  v_s   emp.ename%type;
begin
  open s3;
  fetch s3
    into v_res;
  loop
    exit when s3%notfound;
    update emp set sal = sal * 0.1 + sal where v_res.ename = emp.ename;
    select sal into v_s from emp where emp.ename = v_res.ename;
    if v_s > 5000 then
      rollback;
    else
      commit;
    end if;
    fetch s3
      into v_res;
    close s3;
  end loop;
end;

你可能感兴趣的:(emp表中对所有雇员按他们基本薪水的10%给他们加薪, -- 如果所增加后的薪水大于5000,则取消加薪。)