From: | "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com> |
---|---|
To: | Dave Bolt <dave(at)davebolt(dot)co(dot)uk> |
Cc: | "pgsql-sql(at)lists(dot)postgresql(dot)org" <pgsql-sql(at)lists(dot)postgresql(dot)org> |
Subject: | Re: Stored Procedure to Delete Rows and Return Count |
Date: | 2018-08-29 21:56:28 |
Message-ID: | CAKFQuwbwoXZn4MOdj7nCVwFZDo1GJz2xdP2eDJA+5mBwq5-e-A@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
On Wednesday, August 29, 2018, Dave Bolt <dave(at)davebolt(dot)co(dot)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.
https://www.postgresql.org/docs/9.4/static/plpgsql-statements.html
David J.
From | Date | Subject | |
---|---|---|---|
Next Message | Dave Bolt | 2018-08-29 22:26:46 | RE: Stored Procedure to Delete Rows and Return Count |
Previous Message | Jonathan S. Katz | 2018-08-29 21:56:14 | Re: Stored Procedure to Delete Rows and Return Count |