Is there an SQL instruction to retrieve the value of a sequence that does not increment it.
Thanks.
EDIT AND CONCLUSION
As stated by Justin Cave It’s not useful to try to “save” sequence number so
select a_seq.nextval from dual;
is good enough to check a sequence value.
I still keep Ollie answer as the good one because it answered the initial question. but ask yourself about the necessity of not modifying the sequence if you ever want to do it.
You can get a variety of sequence metadata from
user_sequences,all_sequencesanddba_sequences.These views work across sessions.
EDIT:
If the sequence is in your default schema then:
If you want all the metadata then:
EDIT2:
A long winded way of doing it more reliably if your cache size is not 1 would be:
Just beware that if others are using the sequence during this time – they (or you) may get
Also, you might want to set the cache to
NOCACHEprior to the resetting and then back to its original value afterwards to make sure you’ve not cached a lot of values.