Re: Return serial from insert

Поиск
Список
Период
Сортировка
От Bruno Wolff III
Тема Re: Return serial from insert
Дата
Msg-id 20021115172223.GA3260@wolff.to
обсуждение исходный текст
Ответ на Re: Return serial from insert  (Rory Campbell-Lange <mail@campbell-lange.net>)
Список pgsql-novice
On Fri, Nov 08, 2002 at 16:02:07 +0000,
  Rory Campbell-Lange <mail@campbell-lange.net> wrote:
> The problem is that I need to use the id for naming an image file.
> Consequently I need the id from the insert. You will note (from my
> original messgage) that I'm already using a SERIAL type field for the id
> column.

Then you can select currval of the associated sequence.
currval returns the last value of the sequence assigned by this backend.
So as long as it is the same connection that did the insert and nothing
else using this connection has modified the sequence since the insert,
this will work.

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: core dump in psql (Is it a bug?)
Следующее
От: Bruno Wolff III
Дата:
Сообщение: Re: Efficiency of stored procedure vs large join