Re: Stored Procedure to Delete Rows and Return Count - Mailing list pgsql-sql

From David G. Johnston
Subject Re: Stored Procedure to Delete Rows and Return Count
Date
Msg-id CAKFQuwbwoXZn4MOdj7nCVwFZDo1GJz2xdP2eDJA+5mBwq5-e-A@mail.gmail.com
Whole thread Raw
In response to Stored Procedure to Delete Rows and Return Count  ("Dave Bolt" <dave@davebolt.co.uk>)
List pgsql-sql
On Wednesday, August 29, 2018, Dave Bolt <dave@davebolt.co.uk> wrote:

I am (unfortunately) using PG 8.4

Then writable cte (with) is not an optibn for you.  That requires version 9.1 ROs later.

with d as (delete from foo where id=$1 RETURNING *)

select count(*)


You would have to write “from d” to get that to work but as above the delete only works in 9.1+

I would expect “get diagnostics var = row_count” (something like that) to work after executing delete by itself.  Might want to read more recent docs since the 8.4 seems to not cover this as thoroughly.


David J.

pgsql-sql by date:

Previous
From: "Jonathan S. Katz"
Date:
Subject: Re: Stored Procedure to Delete Rows and Return Count
Next
From: "Dave Bolt"
Date:
Subject: RE: Stored Procedure to Delete Rows and Return Count