"andreas" <postgre...@elbrief.de> writes: > select lastval() ; > lastval > --------- > 2
> i expected lastval() should be 1, because this is the id from the > insertstatement. Well, you can't really rely on that when the statement you're executing contains two different nextval() calls, as this does. The order of evaluation of those calls is unspecified. Personally I'm of the opinion that anyone who uses lastval() deserves to lose, precisely because of the risk of this type of interaction. Use currval() on one or the other of those sequences, and you'll be at least a little bit safer. Even better is to use INSERT RETURNING or some other alternative so that you can avoid currval() too. regards, tom lane -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs