Skip site navigation (1) Skip section navigation (2)

Re: Triggers | rules for column updates

From: "A(dot) Kretschmer" <andreas(dot)kretschmer(at)schollglas(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: Triggers | rules for column updates
Date: 2008-03-03 14:16:26
Message-ID: 20080303141624.GJ22441@a-kretschmer.de (view raw or flat)
Thread:
Lists: 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

In response to

pgsql-novice by date

Next:From: Tom LaneDate: 2008-03-03 21:40:33
Subject: Re: Function problem after alter table
Previous:From: Szentpali JanosDate: 2008-03-03 13:47:58
Subject: Triggers | rules for column updates

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group