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: User Sequence Numbers

Re: User Sequence Numbers

From: DA Morgan <damorgan_at_exesolutions.com>
Date: Fri, 31 Jan 2003 08:51:53 -0800
Message-ID: <3E3AA9A9.7773D1B9@exesolutions.com>


Hermann Angstl wrote:

> Hi,
>
> let's create the following table:
>
> create table foo (k number(5)); -- dont add primary key on k --
> insert into foo values (1);
> insert into foo values (2);
> insert into foo values (3);
> commit;
>
> Is it possible, with the following statement, to create unique numbers ?
> Even with multiple sessions ?
>
> select k from foo where k in (select max(k) from foo) for update of k;
> k++;
> insert into foo values (new_k);
> commit;
>
> ... is there another solution ?
>
> cu,
> hal

CREATE SEQUENCE foo_seq START WITH 1;

INSERT INTO foo VALUES (foo_seq.NEXTVAL);

Daniel Morgan Received on Fri Jan 31 2003 - 10:51:53 CST

Original text of this message

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