Re: Use of nextval, currval

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Josh Berkus" <josh(at)agliodbs(dot)com>
Cc: Matt Clark <mclark(at)rushe(dot)aero(dot)org>, pgsql-novice(at)postgresql(dot)org
Subject: Re: Use of nextval, currval
Date: 2002-11-08 07:29:23
Message-ID: 3343.1036740563@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

"Josh Berkus" <josh(at)agliodbs(dot)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

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Setyo Nugroho 2002-11-08 08:39:15 Where is the saved database?
Previous Message Ludwig Lim 2002-11-08 07:25:18 Some questions on KEYS