Behavior of nextval() and currval()

From: Mike Mascari <mascarm(at)mascari(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Behavior of nextval() and currval()
Date: 2001-11-13 12:30:56
Message-ID: 3BF11280.DAAB8812@mascari.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

The following works in 7.1. Is this behavior guaranteed or is it the
subject of possible change in the future? Or am I just "getting
lucky" that nextval() is evaluated before currval():

CREATE SEQUENCE s;

CREATE TABLE test (
key1 int4,
key2 int4
);

INSERT INTO test
SELECT nextval('s'), currval('s');

SELECT * FROM test;

key1 | key2
------+------
1 | 1

Thanks for any information,

Mike Mascari
mascarm(at)mascari(dot)com

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Marcelo Pereira 2001-11-13 13:33:05 Create Table
Previous Message Justin Clift 2001-11-13 12:04:40 Re: Is data storage secure?