Re: return column id from insert

Поиск
Список
Период
Сортировка
От Oliver Elphick
Тема Re: return column id from insert
Дата
Msg-id 1037111228.11992.817.camel@linda
обсуждение исходный текст
Ответ на return column id from insert  (Rory Campbell-Lange <mail@campbell-lange.net>)
Список pgsql-novice
On Tue, 2002-11-12 at 11:50, Rory Campbell-Lange wrote:
> I asked a question about this earlier, and didn't get a response I
> understood!
>
> The issue is this:
> I need to make a database insert and then make an image with the
> resulting column id number, which is provided by a sequence.
>
> This has to be a single action, otherwise I could fall into a race
> condition with another insert going on concurrently.

Use the function currval('sequence_name') to get the last value
generated by that sequence in your current session.  You must have
previously called nextval('sequence_name') in the same session, either
explicitly or through an insert to a table with a SERIAL type field.

--
Oliver Elphick                                Oliver.Elphick@lfix.co.uk
Isle of Wight, UK
http://www.lfix.co.uk/oliver
GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839  932A 614D 4C34 3E1D 0C1C
                 ========================================
     "He that loveth father of mother more than me is not
      worthy of me; and he that loveth son or daughter more
      than me is not worthy of me. And he that taketh not
      his cross, and followeth after me, is not worthy of
      me."                   Matthew 10:37,38


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

Предыдущее
От: Rory Campbell-Lange
Дата:
Сообщение: return column id from insert
Следующее
От: "Patrick Hatcher"
Дата:
Сообщение: Re: Cancelling long running query?