Re: Insert and obtain the pk

Поиск
Список
Период
Сортировка
От Alvaro Herrera
Тема Re: Insert and obtain the pk
Дата
Msg-id 20031106184527.GA4495@dcc.uchile.cl
обсуждение исходный текст
Ответ на Insert and obtain the pk  ("Eliu Montoya" <eliu@itam.mx>)
Список pgsql-general
On Thu, Nov 06, 2003 at 12:26:48PM -0600, Eliu Montoya wrote:

> Does anyone know an easy way to  insert a record (without a value for the
> primary key because it is a sequence)  and at the same time obtain the value
> of primary key that was assign to this new record.

Given that you are already using a sequence, you can obtain the last
value given to you by means of currval().  No, this doesn't have any
concurrency problems with multiple backends inserting at the same time;
that's exactly the problem it solves.

--
Alvaro Herrera (<alvherre[a]dcc.uchile.cl>)
"In Europe they call me Niklaus Wirth; in the US they call me Nickel's worth.
That's because in Europe they call me by name, and in the US by value!"

В списке pgsql-general по дате отправления:

Предыдущее
От: Oleg Bartunov
Дата:
Сообщение: Re: tsearch2 and gist index bloat
Следующее
От: Peter Eisentraut
Дата:
Сообщение: Re: Install files for version 7.4