Re: Stored Procedure to return resultset from multiple delete statements. - Mailing list pgsql-sql

From David G. Johnston
Subject Re: Stored Procedure to return resultset from multiple delete statements.
Date
Msg-id CAKFQuwY7M+nw-sEJKRt3_hmhpZGrEoXVSH7nbAFTUWJUBCzsPQ@mail.gmail.com
Whole thread Raw
In response to Stored Procedure to return resultset from multiple delete statements.  (Jason Aleski <jason.aleski@gmail.com>)
List pgsql-sql
On Tuesday, August 4, 2015, Jason Aleski <jason.aleski@gmail.com> wrote:
I have a function that will purge an item out of our inventory system.  This script works and displays the appropriate information in the messages/notices pane.  I would like it to return the notices in a resultset format because only developers have access to the messages/notices pane.  I would like to display the results as a resultset in my application.  The problem is that I'm issuing multiple delete commands which cannot be joined.  I tried creating a temp table at the top of the procedure, then inserted data (rows affected) into the table; but I could not get that method to work. Can anyone point me in a direction on what to look at to get the "table affected" and the "number of rows affected by the delete" into some sort of result set?  Below is my current procedure that is working.  There are actually 3 more tables that need to be purged, but I removed those for now.



Your solution will most easily be accomplished using a combination of "delete ... returning", insert, and cte/with.

David J.

pgsql-sql by date:

Previous
From: Jason Aleski
Date:
Subject: Stored Procedure to return resultset from multiple delete statements.
Next
From: "Richard RK. Klingler"
Date:
Subject: Sales report by month and item category