首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > oracle >

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

2012-03-03 
各位大侠帮忙看看下面oracle代码哪错了啊,总说带有编译错误create or replace procedure piscursor c isse

各位大侠帮忙看看下面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; 

热点排行