Re: oid's and primary keys on insert - Mailing list pgsql-general

From Rob Brown-Bayliss
Subject Re: oid's and primary keys on insert
Date
Msg-id 1028923675.1838.14.camel@everglade.zoism.org
Whole thread Raw
In response to oid's and primary keys on insert  (Rob Brown-Bayliss <rob@zoism.org>)
List pgsql-general
On Fri, 2002-08-09 at 21:34, Richard Huxton wrote:

> The standard way of doing this is with a sequence or the SERIAL type (assuming
> you don't have a natural primary key). You can use the currval() and
> nextval() functions to get the last used/next to use values for a given
> sequence. It works with multiple clients and there is now an int8 based
> version for those needing a lot of inserts.

Unfortunatley I am not useing a sequence directly, I am useing a text
field that is like this: 46-X

The X is a sequence, the 46 is site identification number, so that when
I replicate teh data to teh main site their is a way of knowing where it
came from, and also ensuring that the primary key for the table is
unique across several sites.  It is created and inserted by a trigger.

So as you can see I don't actually know what the key will be before an
insert.

Currently I can then get the oid and then get the primary key for that
table row, but if OIDs are banished then I am screwed...

--

*
*  Rob Brown-Bayliss
*

pgsql-general by date:

Previous
From: David Wheeler
Date:
Subject: Suppressing PostgreSQL NOTICEs
Next
From: Rob Brown-Bayliss
Date:
Subject: Re: uncommited question