Oracle sequences have no innate ability to cycle by time -- only by value.
You can, however, cause the sequence to recylce by time in a variety of ways:
1) Use a scheduled task (in Unix, "cron") that runs at mindnight on the morning of the first day of a month that drops and re-creates the sequence at whatever starting value you want.
2) If you have either a trigger or some other PL/SQL procedure that runs regularly, you can introduce a piece of code that checks the SYSDATE, and if it is the first day of the month, it checks the date that the sequence was created (by checking the "CREATED" date in USER_OBJECTS WHERE OBJECT_NAME = '<sequence name>'), and if the the sequence has not yet been created for the month, you can create it in the PL/SQL code with this code:
I'm not sure a trigger would be a feasible solution because the create sequence statement would require an implicit commit and triggers don't allow commits.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.