Re: Use of nextval, currval

Поиск
Список
Период
Сортировка
От Josh Berkus
Тема Re: Use of nextval, currval
Дата
Msg-id web-1817015@davinci.ethosmedia.com
обсуждение исходный текст
Ответ на Use of nextval, currval  (Matt Clark <mclark@rushe.aero.org>)
Ответы Re: Use of nextval, currval
Список 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

В списке pgsql-novice по дате отправления:

Предыдущее
От: Matt Clark
Дата:
Сообщение: Use of nextval, currval
Следующее
От: Ludwig Lim
Дата:
Сообщение: Some questions on KEYS