Oracle存储过程没指定exception范围报错

没有指定exception范围报错得存储过程:

create or replace procedure update_eccif_prod_set is
cursor cursor_one is select role_seq, ac_seq from temp_role_seq_ac_seq;
cur_role_seq temp_role_seq_ac_seq.role_seq%type;
cur_ac_seq temp_role_seq_ac_seq.ac_seq%type;
BEGIN
   open cursor_one;
   loop
   fetch cursor_one into cur_role_seq, cur_ac_seq;
   exit when cursor_one%notfound;
   insert into ICIF.ECCIF_ROLE_PRD_AC(ROLE_SEQ, PRD_ID, AC_SEQ, MAKE_RIGHT, CHECK_RIGHT, AUTH_RIGHT, RELEASE_RIGHT) VALUES(cur_role_seq, 'ent.MCBillCheck', cur_ac_seq, 1, 0, 1, 0);
   exception
     when DUP_VAL_ON_INDEX then null;   
   end loop;
   close cursor_one;
   commit;
END update_eccif_prod_set;

报错信息如下:

Compilation errors for PROCEDURE ICIF.UPDATE_ECCIF_PROD_SET

Error: PLS-00103: 出现符号 "EXCEPTION"在需要下列之一时:
        ( begin
          case declare end exit for goto if loop mod null pragma raise
          return select update while with <an identifier>
          <a double-quoted delimited-identifier> <a bind variable> <<
          continue close current delete fetch lock insert open rollback
          savepoint set sql execute commit forall merge pipe purge
          json_exists json_value json_query json_object json_array
Line: 12
Text: exception

Error: PLS-00103: 出现符号 "CLOSE"在需要下列之一时:
        end not
          pragma final instantiable persistable order overriding static
          member constructor map
Line: 17
Text: close cursor_one;

分析报错信息,联想到java里的try…catch…意识到时捕捉exception时没有指定捕捉范围,程序不会自己想明白范围,所以得明确捕捉exception的范围,通过beginend指定范围。因为分析前在网上搜了下问题,没有解答,只有几个问这问题的,也都没答案,所以记录下。正确代码如下:

create or replace procedure update_eccif_prod_set is
cursor cursor_one is select role_seq, ac_seq from temp_role_seq_ac_seq;
cur_role_seq temp_role_seq_ac_seq.role_seq%type;
cur_ac_seq temp_role_seq_ac_seq.ac_seq%type;
BEGIN
   open cursor_one;
   loop
   fetch cursor_one into cur_role_seq, cur_ac_seq;
   exit when cursor_one%notfound;
   begin
   insert into ICIF.ECCIF_ROLE_PRD_AC(ROLE_SEQ, PRD_ID, AC_SEQ, MAKE_RIGHT, CHECK_RIGHT, AUTH_RIGHT, RELEASE_RIGHT) VALUES(cur_role_seq, 'ent.MCBillCheck', cur_ac_seq, 1, 0, 1, 0);
   exception
     when DUP_VAL_ON_INDEX then null; 
   end;
   end loop;
   close cursor_one;
   commit;
END update_eccif_prod_set;
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值