Re: prepare, execute & oids

Поиск
Список
Период
Сортировка
От Michael Fuhr
Тема Re: prepare, execute & oids
Дата
Msg-id 20060802143951.GA47310@winnie.fuhr.org
обсуждение исходный текст
Ответ на Re: prepare, execute & oids  (phazon <phazon.ml@gmail.com>)
Список 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 по дате отправления:

Предыдущее
От: Sundar Narayanaswamy
Дата:
Сообщение: Re: Autovacuum help..
Следующее
От: "Carlo Stonebanks"
Дата:
Сообщение: Re: Best Procedural Language?