Re: How I can read-back a serial value just inserted?

Поиск
Список
Период
Сортировка
От Bruno Wolff III
Тема Re: How I can read-back a serial value just inserted?
Дата
Msg-id 20070118054909.GA21720@wolff.to
обсуждение исходный текст
Ответ на How I can read-back a serial value just inserted?  ("dfx" <dfx@dfx.it>)
Список pgsql-general
On Mon, Jan 01, 2007 at 18:46:26 +0100,
  dfx <dfx@dfx.it> wrote:
> Dear Sirs,
>
> my question is very simple:
> when I insert a row whith a serial field, a value is automatically
> generated; how  can I know this value, strictly of my row, without the risk
> of to read the value of another subsequent insertion?

Use currval before calling nextval again (including implicitly) in the same
session. (What other sessions are doing won't change the value you see.)

In 8.2 you can use the RETURNING clause to get the value inserted.

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

Предыдущее
От: "Alexi Gen"
Дата:
Сообщение: Newbie questions (pg_global, tablespace, pg_temp, ...)
Следующее
От: Madison Kelly
Дата:
Сообщение: Re: How I can read-back a serial value just inserted?