Re: plpgsql functions and NULLs

From: Don Drake <dondrake(at)gmail(dot)com>
To: Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: plpgsql functions and NULLs
Date: 2005-02-01 02:12:23
Message-ID: 6c21003b05013118121b464bac@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

I'm constraining on other columns as well and it's still picking up the index.

Thanks again.

-Don

On Mon, 31 Jan 2005 16:32:02 -0800 (PST), Stephan Szabo
<sszabo(at)megazone(dot)bigpanda(dot)com> wrote:
> 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(at)megazone(dot)bigpanda(dot)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)
>

--
Donald Drake
President
Drake Consulting
http://www.drakeconsult.com/
312-560-1574

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Sam Adams 2005-02-01 02:26:30 BLOBs vs BYTEA
Previous Message Stephan Szabo 2005-02-01 00:32:02 Re: plpgsql functions and NULLs