reset sequence on sysdate [message #21203] |
Wed, 17 July 2002 22:58 |
moloy
Messages: 8 Registered: June 2002
|
Junior Member |
|
|
can anybody tell how to reset a sequence on the basis of date
say today it start from 1 and reached upto any value,
next day it will once agian start from 1
|
|
|
|
Re: reset sequence on sysdate [message #21221 is a reply to message #21210] |
Thu, 18 July 2002 12:33 |
andrew again
Messages: 2577 Registered: March 2000
|
Senior Member |
|
|
This techniuqe certainly works - but to save some effort - just set the increment number to the number you want to decrement by and then it resets in one step.
select my_seq.nextval from dual;
2125
alter sequence my_seq increment by -2124;
select my_seq.nextval from dual;
1
You can generalize this into a procedure to reset it to any specified number (useful for synchronizing sequences on different databases - e.g. after you've imported data from one to another). Just remember that you can't set the increment by value to "0" (if the sequence is already at the right value). Just code an IF statement to cater for that one.
|
|
|