Re: Last Insert
От
Steve Lane
Тема
Re: Last Insert
Дата
Msg-id
B8B524D3.A06D%slane@fmpro.com
Ответ на
Re: Last Insert (Stephan Szabo)
Список
Дерево обсуждения
Last Insert Marcelo Pereira <gandalf@sum.desktop.com.br>
Re: Last Insert Stephan Szabo <sszabo@megazone23.bigpanda.com>
Re: Last Insert Steve Lane <slane@fmpro.com>
Re: Last Insert Martijn van Oosterhout <kleptog@svana.org>
Re: Last Insert Steve Lane <slane@fmpro.com>
Re: Last Insert Martijn van Oosterhout <kleptog@svana.org>
Re: Last Insert Steve Lane <slane@fmpro.com>
Re: Last Insert "Peter Darley" <pdarley@kinesis-cem.com>
Re: Last Insert Darren Ferguson <darren@crystalballinc.com>
On 3/13/02 10:58 AM, "Stephan Szabo" wrote:
> On Wed, 13 Mar 2002, Marcelo Pereira wrote:
>
>> Hello All,
>>
>> I have two tables, the first is parental and the second is a child of the
>> first.
>>
>> Ex.:
>>
>> create table first (id SERIAL, descrip CHAR(20));
>> create table second (id INTEGER references first(id), state CHAR(2));
>>
>> I have `all' the values to make the inserts in the two tables (ie, descrip
>> and state), so I `would' use:
>>
>> INSERT into first (descrip) values ($descr);
>> INSERT into second (id,state) values (?????????,$state);
>
> currval('first_id_seq') should get you the last sequence value given to
> your session.
I havw a question. Is this reliable even in a connection-pooled environment?
I've always been a little scared of any possible concurrency issues here so
I usually look at the result of the INSERT to get the oid, then use the oid
to query for my key. Am I being too cautious?
-- steve
В списке pgsql-general по дате отправления