亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

以下問題很疑惑,請問在oracle存儲過程中建立序列,但是報錯,求原因!

以下問題很疑惑,請問在oracle存儲過程中建立序列,但是報錯,求原因!

12345678_0001 2021-07-20 18:14:19
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 然后就報錯更新序列號失??! 為什么
查看完整描述

2 回答

?
收到一只叮咚

TA貢獻1821條經驗 獲得超5個贊

序列主要是用來生成固定的編號的,如:每次遞增一即可。
create sequence SEQ_ID
minvalue 1
maxvalue 99999999
start with 1
increment by 1
cache 30
cycle;
之后執行:
insert into tab (auto_id) values (SEQ_ID.Nextval);
備注:sequence 是一個自增長的序列,每次調用nextval的時候會自動增加,可以定義起始值,最大值,增量,cycle是表示循環,即到最大值后從起始值重新開始。 每次執行都是會自增的。

查看完整回答
反對 回復 2021-07-26
?
POPMUISE

TA貢獻1765條經驗 獲得超5個贊

execute immediate 'create SEQUENCE gl_voucher_num INCREMENT BY 1 START WITH 500 NOMAXVALUE NOCYCLE CACHE 10' return varchar2 authid current_user; 語法錯誤,注意引號位置

查看完整回答
反對 回復 2021-07-26
  • 2 回答
  • 0 關注
  • 390 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號