From: | Kevin Grittner <kgrittn(at)ymail(dot)com> |
---|---|
To: | Clemens Eisserer <linuxhippy(at)gmail(dot)com>, "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: BEFORE UPDATE trigger doesn't change column value |
Date: | 2013-04-06 13:52:06 |
Message-ID: | 1365256326.76058.YahooMailNeo@web162905.mail.bf1.yahoo.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Clemens Eisserer <linuxhippy(at)gmail(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | Kevin Grittner | 2013-04-06 14:49:03 | Re: BEFORE UPDATE trigger doesn't change column value |
Previous Message | rudolf | 2013-04-06 10:57:22 | how to get collation according to Unicode Collation Algorithm? |