Re: [GENERAL] new rows based on existing rows

2012-05-02 Thread Alban Hertroys
On 3 May 2012, at 24:00, Tom Lane wrote: > Andy Chambers writes: >> So ideally, I'd like to be able to do > >> insert into foo (a,b,foo_date) >> select a,b,now() from foo old where >> returning oid, old.oid > >> ...but this doesn't work. It seems you only have access to the table >> bei

Re: [GENERAL] new rows based on existing rows

2012-05-02 Thread Tom Lane
Andy Chambers writes: > So ideally, I'd like to be able to do > insert into foo (a,b,foo_date) > select a,b,now() from foo old where > returning oid, old.oid > ...but this doesn't work. It seems you only have access to the table > being modified in a returning clause. Hm ... it is kin

Re: [GENERAL] new rows based on existing rows

2012-05-02 Thread Chris Angelico
On Wed, May 2, 2012 at 10:52 PM, Andy Chambers wrote: > So ideally, I'd like to be able to do > > insert into foo (a,b,foo_date) >  select a,b,now() from foo old where >  returning oid, old.oid > > ...but this doesn't work.  It seems you only have access to the table > being modified in a ret

[GENERAL] new rows based on existing rows

2012-05-02 Thread Andy Chambers
Hi, I frequently have a need to insert new rows into a table that are based on existing rows but with small changes. This is easy using something like insert into foo (a,b,foo_date) select a,b,now() from foo old where returning oid However in the application layer, I need to know which