Re: BEFORE UPDATE trigger doesn't change column value - Mailing list pgsql-general

From Kevin Grittner
Subject Re: BEFORE UPDATE trigger doesn't change column value
Date
Msg-id 1365256326.76058.YahooMailNeo@web162905.mail.bf1.yahoo.com
Whole thread Raw
In response to Re: BEFORE UPDATE trigger doesn't change column value  (Clemens Eisserer <linuxhippy@gmail.com>)
Responses Re: BEFORE UPDATE trigger doesn't change column value
List pgsql-general
Clemens Eisserer <linuxhippy@gmail.com> wrote:

> Here is what I am trying to achieve: Set "synced" to false at any
> update, except when it has been set explicitly to true.
> This does not seem to be possible, without checking the value SET
> by UPDATE?

Right; since there is no way to check whether a 'true' value there
was explicitly set or just carrying over from the old version of
the row without being set, you need some other mechanism for
handling this.  You could, for exampe, add a "force_sync" column
which could be tested in a trigger.  Your BEFORE UPDATE trigger
could leave the "synced" value in NEW alone if force_sync was
false, and set "synced" to false otherwise.  It could then set
NEW.force_sync to false, to leave you ready for the next update.

--
Kevin Grittner
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


pgsql-general by date:

Previous
From: rudolf
Date:
Subject: how to get collation according to Unicode Collation Algorithm?
Next
From: brad st
Date:
Subject: Source code and database object identifiers