From: | Doug McNaught <doug(at)wireboard(dot)com> |
---|---|
To: | "Gregory Wood" <gregw(at)com-stock(dot)com> |
Cc: | "PostgreSQL-General" <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Update Triggers & NULLs |
Date: | 2001-05-02 19:33:36 |
Message-ID: | m38zkfo8a7.fsf@belphigor.mcnaught.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
"Gregory Wood" <gregw(at)com-stock(dot)com> writes:
> I have a plpgsql update trigger on one of my tables. The intention of the
> trigger is to check to see if a particular field is updated, and if so
> INSERT a record into another table. The IF statement looks something like
> this:
>
> IF new.MyField <> old.MyField THEN
>
> This works great when MyField has an actual value and is being changed to a
> new value. The problem is the <> expression is false if new.MyField or
> old.MyField are NULL.
>
> Is there a way to do this without having to write three different boolean
> expressions?
No, you need to check for NULL explicitly using ISNULL. Is there some
problem with using three expressions?
-Doug
--
The rain man gave me two cures; he said jump right in,
The first was Texas medicine--the second was just railroad gin,
And like a fool I mixed them, and it strangled up my mind,
Now people just get uglier, and I got no sense of time... --Dylan
From | Date | Subject | |
---|---|---|---|
Next Message | Gregory Wood | 2001-05-02 19:34:00 | Re: update ... from where id in (..) question |
Previous Message | Mike Mascari | 2001-05-02 19:26:46 | RE: update ... from where id in (..) question |