当前位置: 代码迷 >> Oracle技术 >> 各位大侠帮忙看看下面oracle代码哪错了啊总说带有编译异常
  详细解决方案

各位大侠帮忙看看下面oracle代码哪错了啊总说带有编译异常

热度:99   发布时间:2016-04-24 08:36:37.0
各位大侠帮忙看看下面oracle代码哪错了啊,总说带有编译错误

 create or replace procedure p
  is

  cursor c is 
  select * from emp2 for update;
  begin
  for v_emp in c loop
  if (v_emp.deptno = 10) then
  update emp2 set sal = sal + 10 where current of c;
  elsif (v_emp.deptno = 20) then
  update emp2 set sal = sal + 20 where current of c;
  else
  update emp2 set sal = sal + 50 where current of c;
  end if;
  end loop;
  commit;
  end;
 /

------解决方案--------------------
编译通过,我用的是Scott方案下的emp表,你可以改回你的emp2表.
SQL code
CREATE OR REPLACE PROCEDURE pIS    CURSOR c IS SELECT * FROM emp FOR UPDATE;BEGIN    FOR v_emp IN c     LOOP        IF v_emp.deptno = 10 THEN            UPDATE emp SET sal = sal + 10 WHERE CURRENT OF c;        ELSIF (v_emp.deptno = 20) THEN            UPDATE emp SET sal = sal + 20 WHERE CURRENT OF c;        ELSE            UPDATE emp SET sal = sal + 50 WHERE CURRENT OF c;        END IF;    END LOOP;    COMMIT;END;
  相关解决方案