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: Hans van Dam <LandRoverManREMOVETHIS_at_tiscalimail.nl>
Date: Fri, 31 Jan 2003 11:04:03 GMT
Message-ID: <3e3a5785.594606515@pollux.casema.net>


On Fri, 31 Jan 2003 10:31:16 +0100, Hermann Angstl <hal_at_camline.com> 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

It seems almost too simple, but have'nt you heard of Oracle sequences? Maybe I didnt understand your question, but that seems like THE solution, in fact sequences are specifically designed to fulfill the function of creating unique numbers.

Regards,

Hans van Dam. Received on Fri Jan 31 2003 - 05:04:03 CST

Original text of this message

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