Re: BUG #1083: Insert query reordering interacts badly with NEXTVAL()/CURRVAL()

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Martin Langhoff (Catalyst IT)" <martin(at)catalyst(dot)net(dot)nz>
Cc: PostgreSQL Bugs List <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: BUG #1083: Insert query reordering interacts badly with NEXTVAL()/CURRVAL()
Date: 2004-02-24 06:51:55
Message-ID: 18920.1077605515@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-sql

"Martin Langhoff (Catalyst IT)" <martin(at)catalyst(dot)net(dot)nz> writes:
> Thanks for the clarification. I am curious, however: I can't find a
> means to achieve the same effect in a deterministic manner. Any pointers?

How about

SELECT nextval('seq'); -- ignore result

INSERT INTO ... VALUES (currval('seq'), currval('seq'));

regards, tom lane

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Gary WAN 2004-02-24 10:07:46 The syntax about CREATE DOMAIN
Previous Message Martin Langhoff (Catalyst IT) 2004-02-24 06:46:44 Re: BUG #1083: Insert query reordering interacts badly with

Browse pgsql-sql by date

  From Date Subject
Next Message George A.J 2004-02-24 10:02:00 Enterprice support in PostgreSQL
Previous Message Martin Langhoff (Catalyst IT) 2004-02-24 06:46:44 Re: BUG #1083: Insert query reordering interacts badly with