3 liens privés
define CPT_CODE=&1 --10000
set serveroutput on;
create or replace
procedure reset_seq( p_seq_name in varchar2, future_value in number)
is
l_val number;
owner varchar2(100);
begin
execute immediate 'select table_owner||''.''||synonym_name from user_synonyms where synonym_name=''' || p_seq_name ||'''' into owner;
execute immediate 'select ' || owner || '.nextval from dual' INTO l_val;
execute immediate 'alter sequence ' || owner || ' increment by -' || l_val || ' minvalue 0';
execute immediate 'select ' || owner || '.nextval from dual' INTO l_val;
execute immediate 'alter sequence ' || owner || ' increment by ' || future_value || ' minvalue 0';
execute immediate 'select ' || owner || '.nextval from dual' INTO l_val;
execute immediate 'alter sequence ' || owner || ' increment by 1 minvalue 0';
end;
/
execute reset_seq('CPT_CODE, 500000);
drop procedure reset_seq;