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

Home -> Community -> Usenet -> c.d.o.server -> Re: sequence.nextval question

Re: sequence.nextval question

From: Sybrand Bakker <postbus_at_sybrandb.demon.nl>
Date: Sun, 20 Aug 2000 22:23:37 +0200
Message-ID: <966802951.18109.5.pluto.d4ee154e@news.demon.nl>

Use
select sequence.nextval
into <any variable>
from dual;

and your problem should be resolved.

Hth,

Sybrand Bakker, Oracle DBA

<rmarkd_at_my-deja.com> wrote in message news:8no1no$r1r$1_at_nnrp1.deja.com...
> Note: using Oracle 7.3.4. Don't know what version of OAS.
>
> I'm using an MS-Access front end (to create entry forms and reports)
> which will insert data to an Oracle table. In the Oracle table there
> will be a field named ID which will hold a unique numeric incremental
> value. So, I've created a sequence for this and through an http request
> via OAS (since I don't know how to get a sequence.nextval from Access
> directly), I will request the nextval. The problem is that I can't seem
> to guanantee that two users entering something concurrently will not
> ever end up getting the same ID.
>
> Here's the scenario I'm thinking of:
> Person1 calls the sequence.nextval which returns the number 1000.
> Person2 calls the sequence.nextval which returns the number 1001.
> Person1 gets the max(ID) which will be 1001.
> Person2 gets the max(ID) which will also be 1001.
>
> The problem is that in PL/SQL I can't seem to put sequence.nextval into
> a variable directly, but can only stick it in part of an INSERT
> statement.
>
> Is there a way that I can directly return the value created by
> sequence.nextval? Like I said, I'd love to be able to just declare
> a variable and have it equal to sequence.nextval, but that doesn't seem
> possible. And if there isn't a way, I wonder why Oracle would restrict
> it. It's a sequence, only a sequence, you should be able to do anything
> with it you want to.
>
> Thanks, in advance,
> Mark
>
>
>
>
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
Received on Sun Aug 20 2000 - 15:23:37 CDT

Original text of this message

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