Re: prepare, execute & oids - Mailing list pgsql-general

From Michael Fuhr
Subject Re: prepare, execute & oids
Date
Msg-id 20060802143951.GA47310@winnie.fuhr.org
Whole thread Raw
In response to Re: prepare, execute & oids  (phazon <phazon.ml@gmail.com>)
List pgsql-general
On Wed, Aug 02, 2006 at 09:25:43AM +0200, phazon wrote:
> I use PHP.
> When I make juste a simple insert like
>
> Insert Into my_table (my_field) values ('value')
>
> I get back the OID of the inserted line.
>
> But when i use the prepareInsert fonction, I get nothing back. That's a
> pprobleme becaus i need to take the primary key of the line inserted in
> order to make post-operations.

The PHP source code has no prepareInsert function -- are you using
a third-party module?  If so then try contacting that module's
maintainer.  But as I mentioned previously and as Martijn pointed
out, OIDs aren't suitable as primary keys.  See the documentation
and FAQ:

http://www.postgresql.org/docs/8.1/interactive/datatype-oid.html
http://www.postgresql.org/docs/faqs.FAQ.html#item4.12

> I can't use the curval of a sequence because it can be the value of another
> insert made by another user.

As Martijn and Chris mentioned, currval() is safe in this respect.
Its behavior is documented and is the subject of an FAQ item:

http://www.postgresql.org/docs/8.1/interactive/functions-sequence.html
http://www.postgresql.org/docs/faqs.FAQ.html#item4.11.3

--
Michael Fuhr

pgsql-general by date:

Previous
From: Sundar Narayanaswamy
Date:
Subject: Re: Autovacuum help..
Next
From: "Carlo Stonebanks"
Date:
Subject: Re: Best Procedural Language?