用先删除再生成的方法重置序列

CREATE OR REPLACE PROCEDURE BIFS_CREATEBUSSNO_SEQ_RESET(V_SEQNAME VARCHAR2) Authid Current_User AS
TSQL1 VARCHAR2(300);
TSQL2 VARCHAR2(300);
BEGIN

select 'drop sequence '||sequence_name into TSQL1
from user_sequences where sequence_name = V_SEQNAME;

select 'create sequence '||sequence_name||'
minvalue '||user_sequences.min_value||'
maxvalue '||user_sequences.max_value||'
start with 1
increment by 1
cache '||user_sequences.cache_size into TSQL2
from user_sequences where sequence_name = V_SEQNAME;

if TSQL1 is not null and TSQL2 is not null then
  execute immediate TSQL1;
  execute immediate TSQL2;
end if;
END BIFS_CREATEBUSSNO_SEQ_RESET;

 

posted @ 2021-06-18 14:32  涂山有雨  阅读(56)  评论(0编辑  收藏  举报