Skip site navigation (1) Skip section navigation (2)

Re: target list evaluation wrt sequences

From: Bruno Wolff III <bruno(at)wolff(dot)to>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: target list evaluation wrt sequences
Date: 2004-04-25 11:09:23
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-general
On Sat, Apr 24, 2004 at 16:03:24 -0700,
  elein <elein(at)varlena(dot)com> wrote:
> I have an insert using a select of sequences.
> insert into ...
> 	select
> 		nextval('n') as a,
> 		currval('n') as b,
> 		...
> 	from lalala
> ;
> Is the order of the target list guaranteed?
> That is, will the a and b in the above selection
> *always* be the same?  

No. You can do effectively this by joining a select nextval to whatever
you main select is. Something like:
insert into ...
       select a.n as a, a.n as b, ....
             from (select nextval('n') as n) as a, lalala

In response to


pgsql-general by date

Next:From: Bruce MomjianDate: 2004-04-25 13:57:07
Subject: Re: thread_test.c problems
Previous:From: Bruno Wolff IIIDate: 2004-04-25 10:59:30
Subject: Re: Install plpython

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group