Re: using sequences

Поиск
Список
Период
Сортировка
От Tino Wildenhain
Тема Re: using sequences
Дата
Msg-id 3EEC8758.7050204@wildenhain.de
обсуждение исходный текст
Ответ на using sequences  (Erik Price <eprice@ptc.com>)
Список pgsql-general
Hi Erik,

Erik Price wrote:
> I have read the manual about sequences and I thought I understood both
> their purpose and how to use them.  When I perform inserts, the sequence
> is updated appropriately.  However, I can't seem to directly access the
> sequence myself.  I always seem to get this message:
>
> be_db=# select currval('news_news_id_seq');
> ERROR:  news_news_id_seq.currval is not yet defined in this session
>
> Can someone explain what is going on?

This is a FAQ. Although it is mentioned clearly in the documentation,
it is often overread:

currval() is only valid after nextval() in your transaction.
This is to get the id for your last insert or whatever and
_not_ the id of some other insert concurrently running.

Does this help?

Regards
Tino Wildenhain


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

Предыдущее
От: "Robert C. Paulsen Jr."
Дата:
Сообщение: Re: crypt vs password in pg_hba.conf
Следующее
От: John Smith
Дата:
Сообщение: Re: Lyris -> PG 7.1.3