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?