Re: freezing a particular field in a table
От | Michael Fuhr |
---|---|
Тема | Re: freezing a particular field in a table |
Дата | |
Msg-id | 20051123175522.GA3828@winnie.fuhr.org обсуждение исходный текст |
Ответ на | Re: freezing a particular field in a table (hubert depesz lubaczewski <depesz@gmail.com>) |
Ответы |
Re: freezing a particular field in a table
|
Список | pgsql-admin |
On Wed, Nov 23, 2005 at 10:28:01AM +0100, hubert depesz lubaczewski wrote: > IF > (NEW.some_field IS NULL AND OLD.some_field IS NOT NULL) > OR > (NEW.some_field IS NOT NULL AND OLD.some_field IS NULL) > OR > (NEW.some_field IS NOT NULL AND OLD.some_field IS NOT NULL > AND NEW.some_field <> OLD.some_field) > THEN A more succinct expression would be: 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. > 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. -- Michael Fuhr
В списке pgsql-admin по дате отправления: