Detecting changes to certain fields in 'before update' trigger functions - Mailing list pgsql-general

From Sebastian Tennant
Subject Detecting changes to certain fields in 'before update' trigger functions
Date
Msg-id ljuzkjok.fsf@vps203.linuxvps.org
Whole thread Raw
Responses Re: Detecting changes to certain fields in 'before update' trigger functions  (Adrian Klaver <aklaver@comcast.net>)
Re: Detecting changes to certain fields in 'before update' trigger functions  ("Richard Broersma" <richard.broersma@gmail.com>)
List pgsql-general
Hi list,

First steps in trigger functions and PL/pgSQL so please bear with me...

How can one detect changes to certain fields in before update trigger
functions?

 IF (NEW.<column-name> != OLD.<column-name>) THEN ...

doesn't work, so obviously my understanding of the values of the
varriables NEW and OLD in before update trigger functions is wrong; I
had thought that OLD holds the record as it was before the update, and
that NEW holds the record as it is since the update (but before the
update has been committed)?

How should one go about detecting changes to certain fields in before
update trigger functions?

Any help/advice much appreciated.

Sebastian

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: Cannot open include file: 'nodes/nodes.h'
Next
From: Adrian Klaver
Date:
Subject: Re: Trigger before delete does fire before, but delete doesn't not happen