Re: Use of nextval, currval

From: "Josh Berkus" <josh(at)agliodbs(dot)com>
To: 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 00:53:32
Message-ID: web-1817015@davinci.ethosmedia.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Matt,

> I'm attempting to convert a code which uses Oracle to Postgres.
>
> I am concerned about a couple of points in the SQL, which I should be
> able to do
> in Postgres.
>
> Say I have defined a sequence DataId;
>
> The Oracle uses the sequence as follows:
>
> insert into TABLE (id1,.......,id2)
> values (DataId.NextVal,......,DataId.Currval);
>
> 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. Please post if you for some reason find them not
equal.

-Josh Berkus

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Ludwig Lim 2002-11-08 07:25:18 Some questions on KEYS
Previous Message Matt Clark 2002-11-07 23:15:56 Use of nextval, currval