From: | Rob Brown-Bayliss <rob(at)zoism(dot)org> |
---|---|
To: | Richard Huxton <dev(at)archonet(dot)com> |
Cc: | PostgreSQL General List <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: oid's and primary keys on insert |
Date: | 2002-08-09 20:07:56 |
Message-ID: | 1028923675.1838.14.camel@everglade.zoism.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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
*
From | Date | Subject | |
---|---|---|---|
Next Message | Rob Brown-Bayliss | 2002-08-09 20:11:22 | Re: uncommited question |
Previous Message | Jeff MacDonald | 2002-08-09 17:53:48 | Re: I am being interviewed by OReilly |