Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: How get the current value from a sequence?

Re: How get the current value from a sequence?

From: DA Morgan <damorgan_at_x.washington.edu>
Date: Mon, 06 Dec 2004 08:20:05 -0800
Message-ID: <1102349906.179058@yasure>


Bricklen wrote:

> DA Morgan wrote:
> 

>> Craig & Co. wrote:
>>
>>>> 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.
>>
>> No need to apologize ... but I'd sure like the name of the book
>> so I can warn my students away from it.
> 
> Why warn away from that book? Unless I'm reading that explanation from 
> the book incorrectly, it says exactly what you said.

This seems to be my day to be correct. Agreed. Thanks.

-- 
Daniel A. Morgan
University of Washington
damorgan_at_x.washington.edu
(replace 'x' with 'u' to respond)
Received on Mon Dec 06 2004 - 10:20:05 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US