Code Project

Link Unit

Friday, October 30, 2009

How to find the current value of a sequence number

This seems to be a simple question , and the following error will appear if we try currval on a sequence.

Select s.currval from dual

ORA-08002: sequence S.CURRVAL is not yet defined in this session

CURRVAL doesn't represent anything global about the sequence number generator. It only represents the value returned to your session (the database session processing the current statements) the last time you called NEXTVAL for that sequence

Solutions :
#1 before using CURRVAL you should call NEXTVAL .
#2 You can get the current value of the Sequence by querying DBA_SEQUENCES , which is Last_number.

1 comment:

Amit said...

sahi hain gurudev...