Re: Use of nextval, currval - Mailing list pgsql-novice

From Tom Lane
Subject Re: Use of nextval, currval
Date
Msg-id 3343.1036740563@sss.pgh.pa.us
Whole thread Raw
In response to Re: Use of nextval, currval  ("Josh Berkus" <josh@agliodbs.com>)
List pgsql-novice
"Josh Berkus" <josh@agliodbs.com> writes:
>> I believe that I can replace this in Postgres with:
>>
>> insert into TABLE (id1,.......,id2)
>> values (nextval('DataId'),.....,currval('DataId');
>>
>> What I think is expected is that the values of id1 and id2 will be
>> equal.

> This is correct.

Well ... it's relying on the assumption that the elements of the VALUES
list will be evaluated left-to-right.  Which is true at the moment,
and I don't really expect it to change, but it still could be called an
unsafe dependency on undocumented implementation details.  I doubt you
will find anything in the SQL spec that requires implementations to
behave that way.

            regards, tom lane

pgsql-novice by date:

Previous
From: Ludwig Lim
Date:
Subject: Some questions on KEYS
Next
From: Setyo Nugroho
Date:
Subject: Where is the saved database?