Re: Using results from DELETE ... RETURNING - Mailing list pgsql-general

From Tom Lane
Subject Re: Using results from DELETE ... RETURNING
Date
Msg-id 13938.1244242313@sss.pgh.pa.us
Whole thread Raw
In response to Re: Using results from DELETE ... RETURNING  (Joshua Tolley <eggyknap@gmail.com>)
Responses Re: Using results from DELETE ... RETURNING
List pgsql-general
Joshua Tolley <eggyknap@gmail.com> writes:
> On Mon, Jun 01, 2009 at 04:21:27PM +0100, Shak wrote:
>> Something like:
>> SELECT COUNT(*) FROM (DELETE FROM a RETURNING *) ;
>> sounds reasonable but results in a syntax error. I am able to return single
>> results into a variable or record, but not more than one result.

> You can't. It's on the TODO list (http://wiki.postgresql.org/wiki/Todo).

I think you can loop over the results in plpgsql, for instance

    for rec in DELETE FROM a RETURNING * loop
        ... do something with rec ...
    end loop;

            regards, tom lane

pgsql-general by date:

Previous
From: Joshua Tolley
Date:
Subject: Re: Using results from DELETE ... RETURNING
Next
From: Merlin Moncure
Date:
Subject: Re: Using results from DELETE ... RETURNING