Re: Stored Procedure to return resultset from multiple delete statements.

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Jason Aleski <jason(dot)aleski(at)gmail(dot)com>
Cc: "pgsql-sql(at)postgresql(dot)org" <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Stored Procedure to return resultset from multiple delete statements.
Date: 2015-08-05 05:21:10
Message-ID: CAKFQuwY7M+nw-sEJKRt3_hmhpZGrEoXVSH7nbAFTUWJUBCzsPQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Tuesday, August 4, 2015, Jason Aleski <jason(dot)aleski(at)gmail(dot)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.

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Richard RK. Klingler 2015-08-06 16:16:33 Sales report by month and item category
Previous Message Jason Aleski 2015-08-05 03:54:29 Stored Procedure to return resultset from multiple delete statements.