I need to forward a set of sequences with only DML access. Due to a bug in a piece of code several values were grabbed without a sequence but instead manually, so now the sequence is duplicating those values. So, I would like to push the sequence to the max value so that the next time nextval is called, it gives a value higher than the maximum. I’ve got about 50 sequences that each have to go a few thousand forward.
Is this possible with only DML access? If so, how should I go about it?
You can use dynamic SQL to do this. For example, this bit of code will select the next 10,000 values from each of a list of sequences.
If you had the ability to issue DDL against the sequence, you could use a similar approach to set the
INCREMENTto 10,000, select one value from the sequence, and set theINCREMENTback down to 1 (or whatever it is now).