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.htmlhttp://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.htmlhttp://www.postgresql.org/docs/faqs.FAQ.html#item4.11.3
--
Michael Fuhr