Re: Using results from DELETE ... RETURNING

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Joshua Tolley <eggyknap(at)gmail(dot)com>
Cc: Shak <sshaikh(at)hotmail(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: Using results from DELETE ... RETURNING
Date: 2009-06-05 22:51:53
Message-ID: 13938.1244242313@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

Joshua Tolley <eggyknap(at)gmail(dot)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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Merlin Moncure 2009-06-05 23:03:52 Re: Using results from DELETE ... RETURNING
Previous Message Joshua Tolley 2009-06-05 21:45:33 Re: Using results from DELETE ... RETURNING

Browse pgsql-hackers by date

  From Date Subject
Next Message Merlin Moncure 2009-06-05 23:03:52 Re: Using results from DELETE ... RETURNING
Previous Message Tom Lane 2009-06-05 22:49:08 Re: 8.4b2 tsearch2 strange error