Update Triggers & NULLs

From: "Gregory Wood" <gregw(at)com-stock(dot)com>
To: "PostgreSQL-General" <pgsql-general(at)postgresql(dot)org>
Subject: Update Triggers & NULLs
Date: 2001-05-02 16:52:18
Message-ID: 002101c0d328$41a24500$7889ffcc@comstock.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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?

Greg

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Peter Eisentraut 2001-05-02 17:26:18 Re: Serial Type
Previous Message newsreader 2001-05-02 15:54:37 Re: disk usage advice needed