From: hubert depesz lubaczewski <depesz@gmail.com>
To: Michael Fuhr <mike@fuhr.org>
Cc: fmiddleton@verizon.net
Cc: pgsql-admin@postgresql.org
Subject: Re: freezing a particular field in a table
Date: Thu, 24 Nov 2005 08:38:47 +0100
Message-ID: <9e4684ce0511232338t342ba64ena5a3a14c0cfaa555@mail.gmail.com> (raw)
In-Reply-To: <20051123175522.GA3828@winnie.fuhr.org>
References: <4383A9B7.7060008@verizon.net>
<9e4684ce0511230128y77557be3k2507d6eb1575c1e4@mail.gmail.com>
<20051123175522.GA3828@winnie.fuhr.org>
On 11/23/05, Michael Fuhr <mike@fuhr.org> wrote:
>
> IF NEW.some_field IS DISTINCT FROM OLD.some_field THEN
> IS DISTINCT FROM is like <> except that it treats NULL as an ordinary
> value.
thanks - i didn't know about this operator.
> CREATE TRIGGER impossible_to_change BEFORE UPDATE ON some_table FOR EACH
> ROW
> > EXECUTE PROCEDURE impossible_to_change();
> If the table has other triggers and you don't want them to modify
> the value either, then the check should probably go in an AFTER
> trigger.
>
i would rather use before anyway.
the problem with after is that in aftrer - all you can do is to raise
exception. while - if you would like to value to stick - you would ahve to
change the code *and* change trigger declaration. putting it in before
solves the problem.
of course there might be problem with another triggers, but that's another
story.
depesz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-admin@postgresql.org
Cc: depesz@gmail.com, mike@fuhr.org, fmiddleton@verizon.net
Subject: Re: freezing a particular field in a table
In-Reply-To: <9e4684ce0511232338t342ba64ena5a3a14c0cfaa555@mail.gmail.com>
References: <4383A9B7.7060008@verizon.net> <9e4684ce0511230128y77557be3k2507d6eb1575c1e4@mail.gmail.com> <20051123175522.GA3828@winnie.fuhr.org> <9e4684ce0511232338t342ba64ena5a3a14c0cfaa555@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox