From: | Adrian Klaver <aklaver(at)comcast(dot)net> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Cc: | "Daniel Verite" <daniel(at)manitou-mail(dot)org>, "Bob Pawley" <rjpawley(at)shaw(dot)ca> |
Subject: | Re: Updating |
Date: | 2008-03-17 14:16:50 |
Message-ID: | 200803170716.50561.aklaver@comcast.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Monday 17 March 2008 4:54 am, Daniel Verite wrote:
> Adrian Klaver wrote:
> > CREATE FUNCTION foo() RETURNS trigger AS
> > $Body$
> > BEGIN
> > IF NEW.colname != OLD.colname THEN
> > ..."Do something"..;
> > RETURN whatever;
> > ELSE
> > RETURN NEW:
> > END IF;
> > END;
> > $Body$ LANGUAGE plpgsql;
>
> Beware that the "Do something" code path will not be taken when the
> column goes from NULL to non-NULL or non-NULL to NULL.
>
> In the general case where the column is nullable, better use "IS
> DISTINCT FROM" instead of inequality:
> IF NEW.colname IS DISTINCT FROM OLD.colname
>
> Best regards,
> --
> Daniel
> PostgreSQL-powered mail user agent and storage:
> http://www.manitou-mail.org
Thanks for the heads up. This is a case I usually only remember when I start
testing the function.
--
Adrian Klaver
aklaver(at)comcast(dot)net
From | Date | Subject | |
---|---|---|---|
Next Message | Kynn Jones | 2008-03-17 14:22:19 | Re: How to silence psql notices, warnings, etc.? |
Previous Message | AlannY | 2008-03-17 14:10:43 | Get index information from information_schema? |