Re: Stored Procedure to Delete Rows and Return Count
"David G. Johnston" <[email protected]>
| Newsgroups | gmane.comp.db.postgresql.sql |
|---|---|
| Message-ID | <CAKFQuwbwoXZn4MOdj7nCVwFZDo1GJz2xdP2eDJA+5mBwq5-e-A@mail.gmail.com> |
On Wednesday, August 29, 2018, Dave Bolt <[email protected]> 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.