"Kevin Macdonald" <[EMAIL PROTECTED]> writes:
> Now, take these two operations:

> SQL> select currval ('seq')

> returns 11

> SQL> select nextval ('seq'), currval ('seq')

> returns (12, 12)

> I would have expected it to have returned (12, 11).

No, because currval reports the latest nextval result in your session,
and the nextval has already been executed.  This is dependent on order
of execution of select-list items, but at the moment that's always
left-to-right.

> It seems that the value
> of currval above should have been the value immediately before the SQL
> statement was executed -- a value of 11.

Since sequence operations are non-transactional by definition, I'm not
really sure why you'd expect that.

                        regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
       subscribe-nomail command to [EMAIL PROTECTED] so that your
       message can get through to the mailing list cleanly

Reply via email to