Re: A problem with sequences...

Поиск
Список
Период
Сортировка
От Stephan Szabo
Тема Re: A problem with sequences...
Дата
Msg-id 20030221103441.H59965-100000@megazone23.bigpanda.com
обсуждение исходный текст
Ответ на Re: A problem with sequences...  (Dmitry Tkach <dmitry@openratings.com>)
Ответы Re: A problem with sequences...
Список pgsql-general
On Fri, 21 Feb 2003, Dmitry Tkach wrote:

> rapidb=# select last_value from answer_id_seq;
>   last_value
> ------------
>        22124
> (1 row)
>
> rapidb=# select setval ('answer_id_seq', id) from answer order by id desc limit 1;
>   setval
> --------
>    25000
> (1 row)
>
> rapidb=# select currval('answer_id_seq');
>   currval
> ---------
>     21452
> (1 row)
>
> So, the question I have now is - what's going on?
> How come setval() reports 25000, but the currval changes to 21452
> If my query is wrong (and I can't really see what's wrong with it), then why does it report the correct value?

IIRC, currval returns the last value given by the sequence (in nextval) to
this session.  What does a select nextval('answer_id_seq') give you?
21453 or 25001?


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

Предыдущее
От: Stephan Szabo
Дата:
Сообщение: Re: Mutating table (urgent)
Следующее
От: Doug McNaught
Дата:
Сообщение: Re: A problem with sequences...