Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: How get the current value from a sequence?
>
> "Yes you do. Your statement that Daniel is telling you to
> reconsider is the following:
>
> I believe that executing the command
> select seq_name.nextval from dual;
> does not increment the sequence (the first time), but defines
> the sequence for the session.
>
> This is incorrect, and there is no explanation other than it is
> incorrect."
>
> Thanks Galen.
> --
> Daniel A. Morgan
Hi,
When I setup a sequence and exit the database. Come back in and execute
select seq_name.nextval from dual;
It does not increment the sequence number, UNTIL I execute the command again.
If I don't want to increment the sequence, but I still want to find out what
the value
is that I would execute the command
select seq_name.currval from dual;
If I attempt to execute the 'currval' command, BEFORE the 'nextval' command
I get the message
ERROR at line 1:
ORA-08002: sequence SEQ_NAME.CURRVAL is not yet defined in this session
Which is
08002, 00000, "sequence %s.CURRVAL is not yet defined in this session" // *Cause: sequence CURRVAL has been selected before sequence NEXTVAL // *Action: select NEXTVAL from the sequence before selecting CURRVAL
So all in all - I do not need to reconsider my response.
Cheers
Craig.
Received on Sun Dec 05 2004 - 19:22:49 CST