使用游标查询部门为10的员工,并为其增加1000元,我这里测试反馈数据不正确,麻烦请教感谢

declare
cursor c1(dno myemp.deptno%type)
is select * from myemp t where t.deptno = dno;
prec myemp%rowtype;
begin
open c1(10);

loop
fetch c1 into prec;
update myemp t set t.sal=(t.sal+1000) where t.empno = prec.empno;

exit when c1%notfound;

end loop;
close c1;
commit;

end;

--通过oricle那个emp表返回的结果,一共有三个部门为10的员工,测试出来只有两个员工按正常1000元加上去了。但是另外一个却加了2000元,是代码哪里出问题了吗?求指点/

找到问题根源所在了。问题在于update myemp t set t.sal=(t.sal+1000) where t.empno = prec.empno;

exit when c1%notfound;两句语句需要互调。