create or replace package PK_COMMON is
procedure resetsequence_sp (
seq_name IN VARCHAR2, tSql IN Varchar2);
end PK_COMMON;
procedure resetsequence_sp (
seq_name IN VARCHAR2, tSql IN Varchar2);
end PK_COMMON;
create or replace package body PK_COMMON is
PROCEDURE resetsequence_sp (
seq_name IN VARCHAR2, tSql IN Varchar2) AS
startvalue Integer;
temp_has number;
BEGIN
Select count(*) into temp_has From SEQ where SEQ.sequence_name = upper(seq_name);
if (temp_has>0) then
EXECUTE IMMEDIATE 'DROP SEQUENCE ' ||seq_name;
end if;
EXECUTE IMMEDIATE tSql INTO startvalue;
EXECUTE IMMEDIATE 'CREATE SEQUENCE ' || seq_name || ' START WITH ' || startvalue;
END resetsequence_sp;
end PK_COMMON;
PROCEDURE resetsequence_sp (
seq_name IN VARCHAR2, tSql IN Varchar2) AS
startvalue Integer;
temp_has number;
BEGIN
Select count(*) into temp_has From SEQ where SEQ.sequence_name = upper(seq_name);
if (temp_has>0) then
EXECUTE IMMEDIATE 'DROP SEQUENCE ' ||seq_name;
end if;
EXECUTE IMMEDIATE tSql INTO startvalue;
EXECUTE IMMEDIATE 'CREATE SEQUENCE ' || seq_name || ' START WITH ' || startvalue;
END resetsequence_sp;
end PK_COMMON;
SQLPLUS用法
SQL> exec pk_common.resetsequence_sp('s_sys_function','select max(fmid)+1 from s
ys_function');
ys_function');
给用户创建Sequence的权限.否则运行存储过程会报ORA01031
GRANT CREATE ANY sequence TO jtscm
方便使用再发个EXCLE方便批量执行 下载