pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: stan <stanb@panix.com>
To: Christophe Pettus <xof@thebuild.com>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: Can I trigger an action from a coalesce ?
Date: Sat, 22 Feb 2020 16:33:25 -0500
Message-ID: <20200222213325.GA22785@panix.com> (raw)
In-Reply-To: <BF12101F-CC34-4C75-B770-78B544AEEB70@thebuild.com>
References: <20200222210206.GA17445@panix.com>
	<35c60adc-3f02-13ad-a4a6-48642a1185d8@aklaver.com>
	<BF12101F-CC34-4C75-B770-78B544AEEB70@thebuild.com>

On Sat, Feb 22, 2020 at 01:06:57PM -0800, Christophe Pettus wrote:
> 
> 
> > On Feb 22, 2020, at 13:05, Adrian Klaver <adrian.klaver@aklaver.com> wrote:
> > 
> > On 2/22/20 1:02 PM, stan wrote:
> >> I have a case where if a value does not exist, I am going to use a default,
> >> which is easy with coalesce. But I would like to warn the user that a
> >> default has been supplied. The default value is reasonable, and could
> >> actually come from the source table, so I can't just check the value.
> >> I'd like to do a raise NOTICE, if the default portion of the coalesce fires.
> >> Anyone have a good way to accomplish this?
> > 
> > No.
> 
> You can, of course, create a PL/pgSQL function and use that as the default.
I suppose you are suggesting that the function try the original SELECT, and
if it returns a NULL then retun the default AND do the raise NOTICE?

Or is there a simpler way?


-- 
"They that would give up essential liberty for temporary safety deserve
neither liberty nor safety."
						-- Benjamin Franklin





view thread (12+ messages)  latest in thread

Message-ID: <20200222213325.GA22785@panix.com>
Permalink:  ../20200222213325.GA22785@panix.com/
Also on:    postgresql.org/message-id/20200222213325.GA22785@panix.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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: stanb@panix.com, xof@thebuild.com
  Subject: Re: Can I trigger an action from a coalesce ?
  In-Reply-To: <20200222213325.GA22785@panix.com>
  References: <20200222210206.GA17445@panix.com> <35c60adc-3f02-13ad-a4a6-48642a1185d8@aklaver.com> <BF12101F-CC34-4C75-B770-78B544AEEB70@thebuild.com> <20200222213325.GA22785@panix.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