oracle sequence init
- by gospodin
I wanted to export 3 tables from db1 into db2.
Before the export starts, I will create the sequences for those 3 tables.
CREATE SEQUENCE TEST_SEQ START WITH 1 INCREMENT BY 1;
After the export, I will reinitialize sequnce values to match the max(id) + 1 from the table.
CREATE OR REPLACE PROCEDURE "TEST_SEQUENCE"
AUTHID CURRENT_USER
is
v_num number;
begin
select max(ID) into v_num from TABLE_1;
EXECUTE IMMEDIATE 'ALTER SEQUENCE TEST_SEQ INCREMENT BY ' || v_num;
EXECUTE IMMEDIATE 'ALTER SEQUENCE 1TEST_SEQ INCREMENT BY 1';
end;
/
show errors;
execute TEST_SEQ;
This procedure compiles and executes without problems.
But when I want to check t he last value of the sequence, like
select TEST_SEQ.nextval from dual;
I still get the "1".
Can someone tell me why my procedure did not impact my sequence?
ps. I am using oracle sql developper to pass sql.
Thanks