Creation of a unique id - Mailing list pgsql-general

From brian.walsh@ss8.com
Subject Creation of a unique id
Date
Msg-id 88256B3E.0060C498.00@notes.centigram.com
Whole thread Raw
List pgsql-general
Seem to be getting some error messages back regarding this message so just
resending it.
---------------------- Forwarded by Brian Walsh/US/Centigram on 01/11/2002
09:41 AM ---------------------------

Brian Walsh   01/10/2002 05:02 PM
(Embedded image moved to file: pic13896.pcx)

To:   pgsql-general@postgresql.org.
cc:
Subject:  Creation of a unique id

Hi,
I am using the "CREATE SEQUENCE"  combined with nextval() to generate a
unique id as below.

create sequence brian_seq minvalue 32000 maxvalue 32005 CACHE 5 CYCLE;

create table btest
(bar INT PRIMARY KEY DEFAULT nextval('brian_seq'), name TEXT);

My problem comes from the re-use of id's from deleted records.
Lets say Ihave records 1-5 and during the first loop I do the following

INSERT 1...
INSERT 2...
INSERT 3...
DELETE 2...
INSERT 4
INSERT 5

How do I get the database to know the next available msgid available is now
2?
Regards,

Brian



Attachment

pgsql-general by date:

Previous
From: "Steve Boyle \(Roselink\)"
Date:
Subject: Re: Function problem
Next
From: Tom Lane
Date:
Subject: Re: BLOB question + MS Access ODBC issue