pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Stephan Szabo <sszabo@megazone.bigpanda.com>
To: Don Drake <dondrake@gmail.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: plpgsql functions and NULLs
Date: Mon, 31 Jan 2005 16:32:02 -0800 (PST)
Message-ID: <20050131162845.K27545@megazone.bigpanda.com> (raw)
In-Reply-To: <6c21003b05013114272504d72e@mail.gmail.com>
References: <6c21003b0501301141234c256b@mail.gmail.com>
	<20050131132701.G12960@megazone.bigpanda.com>
	<6c21003b05013114272504d72e@mail.gmail.com>

On Mon, 31 Jan 2005, Don Drake wrote:

> You learn something new everyday.  I've never seen that syntax before,
> and it works like a charm!!

Actually, now that I think about it, I wonder if that's a good thing to
use because I don't think that'll use indexes to do the search.  You may
want to do some testing to see how it runs for you.

> On Mon, 31 Jan 2005 13:31:34 -0800 (PST), Stephan Szabo
> <sszabo@megazone.bigpanda.com> wrote:
> >
> > On Sun, 30 Jan 2005, Don Drake wrote:
> >
> > > OK, I have a function that finds records that changed in a set of
> > > tables and attempts to insert them into a data warehouse.
> > >
> > > There's a large outer loop of candidate rows and I inspect them to see
> > > if the values really changed before inserting.
> > >
> > > My problem is that when I look to see if the row exists in the
> > > warehouse already, based on some IDs, it fails when an ID is NULL.
> > > The ID is nullable, so that's not a problem.
> > >
> > > But I'm forced to write an IF statement looking for the potential NULL
> > > and write 2 queries:
> > >
> > > IF omcr_id is null
> > >    select * from ....
> > >    WHERE omcr_id is NULL
> > >    AND ...
> > > ELSE
> > >    select * from ....
> > >    WHERE omcr_id=candidate.omcr_id
> > >    AND ....
> > > END IF;
> >
> > Hmm, perhaps some form like:
> >
> > WHERE not(candidate.omcr_id is distinct from omcr_id)



view thread (9+ messages)  latest in thread

Message-ID: <20050131162845.K27545@megazone.bigpanda.com>
Permalink:  ../20050131162845.K27545@megazone.bigpanda.com/
Also on:    postgresql.org/message-id/20050131162845.K27545@megazone.bigpanda.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-sql@postgresql.org
  Cc: sszabo@megazone.bigpanda.com, dondrake@gmail.com
  Subject: Re: plpgsql functions and NULLs
  In-Reply-To: <20050131162845.K27545@megazone.bigpanda.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