Re: prepare, execute & oids

From: Michael Fuhr <mike(at)fuhr(dot)org>
To: phazon <phazon(dot)ml(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: prepare, execute & oids
Date: 2006-08-02 14:39:51
Message-ID: 20060802143951.GA47310@winnie.fuhr.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Carlo Stonebanks 2006-08-02 14:43:29 Re: Best Procedural Language?
Previous Message Sundar Narayanaswamy 2006-08-02 14:36:09 Re: Autovacuum help..