Search Postgresql Archives

Re: Using results from DELETE ... RETURNING

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

 



On Fri, Jun 5, 2009 at 6:51 PM, Tom Lane<tgl@xxxxxxxxxxxxx> wrote:
> Joshua Tolley <eggyknap@xxxxxxxxx> 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
>
> --
> Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general


also sql functions can direct 'returning' results directly to the
return of the function (at least in 8.4).

merlin

-- 
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