Re: [GENERAL] Using results from DELETE ... RETURNING

2009-06-08 Thread Merlin Moncure
On Sun, Jun 7, 2009 at 12:29 AM, Tom Lane wrote: > David Fetter writes: >> Would it be super-complicated to do this with CTEs for 8.5?  They seem to >> have sane properties like getting executed exactly once. > > Hmm, interesting thought.  The knock against doing RETURNING as an > ordinary subquer

Re: [GENERAL] Using results from DELETE ... RETURNING

2009-06-06 Thread Tom Lane
David Fetter writes: > Would it be super-complicated to do this with CTEs for 8.5? They seem to > have sane properties like getting executed exactly once. Hmm, interesting thought. The knock against doing RETURNING as an ordinary subquery is exactly that you can't disentangle it very well from

Re: [GENERAL] Using results from DELETE ... RETURNING

2009-06-06 Thread David Fetter
On Fri, Jun 05, 2009 at 07:13:43PM -0400, Tom Lane wrote: > Merlin Moncure writes: > > On Fri, Jun 5, 2009 at 6:51 PM, Tom Lane 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 func

Re: [GENERAL] Using results from DELETE ... RETURNING

2009-06-05 Thread Tom Lane
Merlin Moncure writes: > On Fri, Jun 5, 2009 at 6:51 PM, Tom Lane 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

Re: [GENERAL] Using results from DELETE ... RETURNING

2009-06-05 Thread Merlin Moncure
On Fri, Jun 5, 2009 at 6:51 PM, Tom Lane wrote: > Joshua Tolley 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 in

Re: [GENERAL] Using results from DELETE ... RETURNING

2009-06-05 Thread Tom Lane
Joshua Tolley 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.

Re: [GENERAL] Using results from DELETE ... RETURNING

2009-06-05 Thread Joshua Tolley
On Mon, Jun 01, 2009 at 04:21:27PM +0100, Shak wrote: > When RETURNING from a DELETE statement (or similar), how do you access the > results being returned? > > Something like: > > SELECT COUNT(*) FROM (DELETE FROM a RETURNING *) ; > > sounds reasonable but results in a syntax error. I am able to r

[GENERAL] Using results from DELETE ... RETURNING

2009-06-05 Thread Shak
Hi all, When RETURNING from a DELETE statement (or similar), how do you access the results being returned? 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 m