As in the question, how do I automatically reset an Oracle sequence\'s value back to 0 every year in Oracle 10g?
I\'m using the sequence to generate an identifier i
First of all, it doesn't seem to be a way to make the sequence restart automatically every year. Read this for reference:
http://www.psoug.org/reference/OLD/sequences.html?PHPSESSID=5949da378678fa6d24b6fcc6eaae9888
My approach will be:
create a table with the year and the starting sequence for that year (lets call this table year_seed)
create a procedure that receives the year, checks the year_seed table and if it's the first check for the year generates the register with the starting sequence. This procedure must also return the sequence minus the starting sequence for the year.
Maybe it's not so simple but I think it's the best solution. Good luck