| From: | "Daniel Verite" <daniel(at)manitou-mail(dot)org> |
|---|---|
| To: | "Adrian Klaver" <aklaver(at)comcast(dot)net> |
| Cc: | pgsql-general(at)postgresql(dot)org,"Bob Pawley" <rjpawley(at)shaw(dot)ca> |
| Subject: | Re: Updating |
| Date: | 2008-03-17 11:54:21 |
| Message-ID: | 4e715e28-cdbe-4302-b644-5c14180ff5cb@mm |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
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
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Pavan Deolasee | 2008-03-17 12:27:36 | Re: 8.3.0 upgrade |
| Previous Message | Steven Flatt | 2008-03-17 10:53:54 | Re: restore_command %r option |