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: Thu, 02 Dec 2004 16:07:07 -0800
Message-ID: <1102032328.4388@yasure>


Craig & Co. wrote:

> Hi all
>
> DA Morgan wrote in response to
>

>>>whats wrong with select seq_name.nextval fom dual?

>
>
>>One big thing ... that being you just took another number off the
>>top of the sequence.

>
>
> 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.

I believe you should try it.

CREATE TABLE t (
numcol NUMBER(5));

CREATE SEQUENCE seq_t;

INSERT INTO t
(numcol)
SELECT seq_t.NEXTVAL FROM dual;

SELECT * FROM t;

And perhaps reconsider your response.

-- 
Daniel A. Morgan
University of Washington
damorgan_at_x.washington.edu
(replace 'x' with 'u' to respond)
Received on Thu Dec 02 2004 - 18:07:07 CST

Original text of this message

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