procedure gl_voucher_noadd(accyear varchar2,accmonth varchar2,info in out varchar2)isx number ;beginselect max(num) into x from gl_voucher where year=accyear and period=accmonth and pk_group='0001V210000000004MCY';if x=null then x := '500';else x :=x;execute immediate'drop SEQUENCE gl_voucher_num'; --刪除序列commit;end if;execute immediate 'create SEQUENCE gl_voucher_num INCREMENT BY 1 START WITH 500 NOMAXVALUE NOCYCLE CACHE 10 return varchar2 authid current_user';commit;-- 表頭execute immediate 'update gl_voucher a set num =gl_voucher_num.nextval'; /*where nvl(a.free9,'~')!='~' and year=accyear and period=accmonth and pk_group='0001V210000000004MCY'';-- 表體*/execute immediate 'update gl_detail a set nov =(select num from gl_voucher where pk_voucher=a.pk_voucher)'/* where nvl(a.free9,'~')!='~' and yearv=accyear and periodv=accmonth and pk_group='0001V210000000004MCY''*/;info:=info||'序列改變影響行數:'||SQL%rowcount||'; ';exceptionwhen others theninfo:=info||'更新序列號失?。?#39;;end;單步執行的時候運行到execute immediate 'create SEQUENCE gl_voucher_num INCREMENT BY 1 START WITH 500 NOMAXVALUE NOCYCLE CACHE 10 return varchar2 authid current_user';這里的時候直接運行exception 然后就報錯更新序列號失??! 為什么
以下問題很疑惑,請問在oracle存儲過程中建立序列,但是報錯,求原因!
12345678_0001
2021-07-20 18:14:19