Re: Triggers | rules for column updates - Mailing list pgsql-novice

From A. Kretschmer
Subject Re: Triggers | rules for column updates
Date
Msg-id 20080303141624.GJ22441@a-kretschmer.de
Whole thread Raw
In response to Triggers | rules for column updates  (Szentpali Janos <ianus@easynet.ro>)
List pgsql-novice
am  Mon, dem 03.03.2008, um 15:47:58 +0200 mailte Szentpali Janos folgendes:
> Hi!
>
> I want to prevent any changes to a tuple if a field of the tuple has a
> certain value. Let's say I have a table with column col_1, col_2, col_3.
> I want to create something that will prevent updating col_2 and col_3 if
> and only if col_1 is say "1".
> Can I use a rule to do that. Can I somehow detect in a trigger function

I think, a RULE isn't the solution, but you can use a BEFORE UPDATE -
Trigger to check if OLD.col_1 = 1 and, in this case, RAISE an error.



Andreas
--
Andreas Kretschmer
Kontakt:  Heynitz: 035242/47150,   D1: 0160/7141639 (mehr: -> Header)
GnuPG-ID:   0x3FFF606C, privat 0x7F4584DA   http://wwwkeys.de.pgp.net

pgsql-novice by date:

Previous
From: Szentpali Janos
Date:
Subject: Triggers | rules for column updates
Next
From: Sean Dooley
Date:
Subject: Function problem after alter table