Re: Generate a unique number in a record
Date: 1997/11/24
Message-ID: <65bop0$fe9$1_at_news.dknet.dk>#1/1
P de Raad wrote:
> I've the following problem.
>
> Various user can create a record in a table, The created records are deleted
> after a certain amount of time and written to a history. The only key wich
> can be used is a unique number/sequence. Another table is joined with this
> table and uses this field to join both tables ( this is also the case in the
> history).
>
> I want to know how to create a unique number in one INSERT statement. The
> rowid cannot be used because after the records are deleted the rowid can be
> reused again.
>
> Does anyone have suggestions to solve this problem ?
>
> With kind regards
>
> Gijs Schalk
use a sequence, like this
create table some_table ( id number, data varchar(16) ); create sequence some_seq minvalue 1 start with 1 increment by 1;
insert into some_table( some_seq.nextval, 'my data');
regards
Klaus Preisler
Received on Mon Nov 24 1997 - 00:00:00 CET