This will set the sequence of tables to the next value to prevent PK constraint violations when you try to add a record. You can also get other strange, unexplained errors.


PREVENTION: Prevent this problem in the future by utilizing the GETNEXTSEQ function to set the primary key id.  See the GETNEXTSEQ Function solution for instructions.


To run, in SQL+ logged on as biotics_dlink. To execute, enter
set serveroutput on;
exec fix_next_seq;


NOTE: If there are any empty tables, you will need to provide the value at which the sequence should begin (presumably 1).  So,

exec fix_next_seq (1);


You will then get a display of any tables that are found to be out of synch. This will update ONLY the sequence, NOT the PK values in the tables themselves. This is not a bad thing to do after doing a data exchange upload or any kind of a batch update.


If you receive an error upon running the FIX_NEXT_SEQ procedure, refer to this Solution.


The following query will verify that all have been set as expected, however, neither biotics_dlink nor biotics_report have privileges to run it currently.  Instead, compare your results to that in the attached text file, which shows you an example of the expected results when the sequence is successfully run.  Note of course that the sequences and numbers in the attached file will differ from your results - this is merely an example.

select SEQUENCE_NAME, LAST_NUMBER from user_sequences;