Search Postgresql Archives

Re: Using results from DELETE ... RETURNING

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Jun 05, 2009 at 07:13:43PM -0400, Tom Lane wrote:
> Merlin Moncure <mmoncure@xxxxxxxxx> writes:
> > On Fri, Jun 5, 2009 at 6:51 PM, Tom Lane<tgl@xxxxxxxxxxxxx> wrote:
> >> I think you can loop over the results in plpgsql, for instance
> 
> > also sql functions can direct 'returning' results directly to the
> > return of the function (at least in 8.4).
> 
> That bit is new in 8.4, which is why I didn't mention it.  But I
> think the plpgsql loop way works further back.

Would it be super-complicated to do this with CTEs for 8.5?  They seem to
have sane properties like getting executed exactly once.

This could look like:

WITH t AS (
    DELETE FROM foo RETURNING * FROM a
)
INSERT INTO foo_audit ...

Cheers,
David (Yes, I know the spec doesn't have row-changing operations in
either part of the above.  Yet ;)
-- 
David Fetter <david@xxxxxxxxxx> http://fetter.org/
Phone: +1 415 235 3778  AIM: dfetter666  Yahoo!: dfetter
Skype: davidfetter      XMPP: david.fetter@xxxxxxxxx

Remember to vote!
Consider donating to Postgres: http://www.postgresql.org/about/donate

-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux