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?
>
> You are ignoring advice given to you multiple times, in the group's
> archives and well documented on many web sites. So here it is again:
>
> CURRVAL only works within the current session following a NEXTVAL.
>
> Once you end the session CURRVAL is meaningless until you again use
> NEXTVAL which increments the counter yet again.
>
> If you want the current value of a sequence when first logging on
> the only way to do so is a query against one of the xxx_sequence data
> dictionary views.
> --
> Daniel A. Morgan
> University of Washington
> damorgan_at_x.washington.edu
> (replace 'x' with 'u' to respond)
Okay, okay, okay.
I see where I was going wrong.
It does increment the value with a seq_name.nextval.
The book sort of doesn't say that though as it says
The first reference to NEXTVAL returns the sequences's initial value. (This
is where I was going wrong)
Subsequent references to NEXTVAL increment the sequence value by the defined
increment
and return the new value. ( I mentioned this)
Any reference to CURRVAL always returns the sequence's current value, which
is the value returned
by the last reference to NEXTVAL. (Again I mentioned this)
Then I read the next line, which I should have read a long time before now, which says:
Note that before you can use CURRVAL for a sequence in your session, you
must first
increment (There is that magic word) the sequence with NEXTVAL.
I then did further testing which resulted in the answer that you have all
been
trying to pound into me.
Deeply bows to all in apology and backs out the door quietly.
Cheers
Craig.
Received on Sun Dec 05 2004 - 22:41:27 CST