Re: A problem with sequences...

Поиск
Список
Период
Сортировка
От Doug McNaught
Тема Re: A problem with sequences...
Дата
Msg-id m37kbtzdhy.fsf@varsoon.wireboard.com
обсуждение исходный текст
Ответ на Re: A problem with sequences...  (Dmitry Tkach <dmitry@openratings.com>)
Ответы Re: A problem with sequences...
Re: A problem with sequences...
Список pgsql-general
Dmitry Tkach <dmitry@openratings.com> writes:

> select setval('answer_id_seq', id) from answer order by id desc limit 1;
>
> Now, for some reason this reports a correct value, but what actually
> gets set is wrong!

I'm guessing that 'setval' is getting called more than once here.
Your 'LIMIT 1' controls how many rows are returned to the client, but
the server is probably generating more rows internally.  So this is
just wrong, and

> select setval ('answer_id_seq', max(id)) from answer

is right.

-Doug

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

Предыдущее
От: Stephan Szabo
Дата:
Сообщение: Re: A problem with sequences...
Следующее
От: Dmitry Tkach
Дата:
Сообщение: Re: A problem with sequences...