Re: new rows based on existing rows - Mailing list pgsql-general

From Alban Hertroys
Subject Re: new rows based on existing rows
Date
Msg-id 1E0490A0-C990-47B0-B371-FF6501B76A83@gmail.com
Whole thread Raw
In response to Re: new rows based on existing rows  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
On 3 May 2012, at 24:00, Tom Lane wrote:

> Andy Chambers <achambers@mcna.net> 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.
>
> For the moment I think all you could really do is what somebody else
> suggested, namely eat the overhead of having an "old_id" column in
> the table so that you can insert the value you want into that column,
> thus making it available to the RETURNING clause.


I was wondering, would an updatable view with a "pseudo-column" for the old_id do it?

Alban Hertroys

--
Screwing up is an excellent way to attach something to the ceiling.


pgsql-general by date:

Previous
From: Ben Madin
Date:
Subject: Re: SQLSTATE XX000 Internal Error 7
Next
From: Alexander Reichstadt
Date:
Subject: Memory Management in pqlib, Garbage Collection support