為什么顯示代碼錯誤呢?
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;
/
2016-04-09
第14行:update emp set sal=sal*1.1 when empno=pempno;?
這里條件不應該是when,而是where
第20行:dbms_output.put_line(pename||psal);
這里pename未聲明,根據你前面寫的,應該是要寫pname吧
代碼執(zhí)行的時候報錯會提示第幾行第幾列,是什么問題,根據提示修改就可以。