pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Ron <ronljohnsonjr@gmail.com>
To: pgsql-admin@lists.postgresql.org
Subject: Re: SELECTing from a function where i don't want the results
Date: Tue, 7 Jul 2020 19:45:42 -0500
Message-ID: <911059a0-d138-7ea3-044e-0d7ca71755a2@gmail.com> (raw)
In-Reply-To: <CAOC+FBWh780YjwEqHP908RPFVkQ6FU0FN7yQdJzxTYn=uaqgUA@mail.gmail.com>
References: <CAOC+FBXnaxi1yiEv=mL2J1tbnsLfqoneNOnikiQFobdEv=DaWw@mail.gmail.com>
	<CAKFQuwZUVRomU-ca1SDF2oSLg-vaNoXG6ckxkrmD5Pzp=L1-QA@mail.gmail.com>
	<CAOC+FBWh780YjwEqHP908RPFVkQ6FU0FN7yQdJzxTYn=uaqgUA@mail.gmail.com>

Your original question says that the function returns the number of rows 
deleted.  That's one line.  Now you're saying that it returns one row per 
table-row deleted.  Which is it?

On 7/7/20 7:21 PM, Wells Oliver wrote:
> ha, the CTE approach to only get one line of output versus however many 
> hundreds of rows were used for the delete is perfect. Thanks.
>
> On Tue, Jul 7, 2020 at 5:18 PM David G. Johnston 
> <david.g.johnston@gmail.com <mailto:david.g.johnston@gmail.com>> wrote:
>
>     On Tuesday, July 7, 2020, Wells Oliver <wells.oliver@gmail.com
>     <mailto:wells.oliver@gmail.com>> wrote:
>
>         Vanilla SQL script calls a plpgsql function to delete some number
>         of rows from three tables:
>
>         SELECT mydelete(r) FROM sometable;
>
>         Where sometable contains maybe 100+ records. This causes the
>         results from the function (integer of number of rows removed) to
>         be displayed in the output, like you'd kinda expect with a SELECT
>         call, except I don't want to see it all, I just want the function
>         quietly executed and rows removed.
>
>         Can I accomplish this?
>
>
>     Pure SQL, no, you cannot just ignore the output.  You can perform
>     post-processing (via CTE/WITH) to reduce how much is printed
>     (aggregates). If you are using psql you can send it to /dev/null.  You
>     could use a DO block and (kinda) ignore the result (SQL) and/or stick
>     it into a throw-away variable (plpgsql).
>
>     David J.
>
>
>
> -- 
> Wells Oliver
> wells.oliver@gmail.com <mailto:wellsoliver@gmail.com>

-- 
Angular momentum makes the world go 'round.

view thread (16+ messages)  latest in thread

Message-ID: <911059a0-d138-7ea3-044e-0d7ca71755a2@gmail.com>
Permalink:  ../911059a0-d138-7ea3-044e-0d7ca71755a2@gmail.com/
Also on:    postgresql.org/message-id/911059a0-d138-7ea3-044e-0d7ca71755a2@gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-admin@postgresql.org
  Cc: ronljohnsonjr@gmail.com, pgsql-admin@lists.postgresql.org
  Subject: Re: SELECTing from a function where i don't want the results
  In-Reply-To: <911059a0-d138-7ea3-044e-0d7ca71755a2@gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox