Re: BEFORE UPDATE trigger doesn't change column value

From: Clemens Eisserer <linuxhippy(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: BEFORE UPDATE trigger doesn't change column value
Date: 2013-04-05 22:15:27
Message-ID: CAFvQSYRxVBms3e7G2KjCA2qsQeJtASOvgfaJOOr4=vDzUPkW2g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

NEW reflects what the row will look like after the UPDATE. There
> is no way to tell which columns were specified in the SET clause of
> the UPDATE; a column which is omitted from that clause will look
> exactly the same as a column which is set to the value it already
> had.
>

Thanks a lot for clarifying this ... my logic was flawed.
At stackoverflow.com I found an example which suggested testing against
NULL would allow this and I just relied on it.

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?

Regards, Clemens

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Pete Wall 2013-04-05 22:33:07 PostgreSQL Downgrades
Previous Message Gavan Schneider 2013-04-05 21:54:11 Re: BEFORE UPDATE trigger doesn't change column value