set serveroutput on
declare
cursor guangbiao2 is SELECT empno, sal FROM emp order by sal;
pempno emp.empno% TYPE;
psal emp.sal% TYPE;
pname NUMBER:=0;
tolsal NUMBER;
BEGIN
SELECT sum(sal) into tolsal from emp;
open guangbiao2;
loop
exit when tolsal>50000;
fetch guangbiao2 into pempno,psal;
exit when (tolsal + psal*0.1) > 50000;
update emp set sal=sal*1.1 when empno=pempno;
pname:=pname+1;
tolsal:=tolsal+psal*0.1;
end loop;
close guangbiao2;
commit;
dbms_output.put_line(pename||psal);
end;
/
第14行:update emp set sal=sal*1.1 when empno=pempno;
这里条件不应该是when,而是where
第20行:dbms_output.put_line(pename||psal);
这里pename未声明,根据你前面写的,应该是要写pname吧
代码执行的时候报错会提示第几行第几列,是什么问题,根据提示修改就可以。