Re: How to prevent modifications in a tree of rows, based on a condition?

From: "A(dot) Kretschmer" <andreas(dot)kretschmer(at)schollglas(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: How to prevent modifications in a tree of rows, based on a condition?
Date: 2007-06-19 11:18:03
Message-ID: 20070619111802.GB7819@a-kretschmer.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

am Tue, dem 19.06.2007, um 12:23:51 +0200 mailte Philippe Lang folgendes:
>
> I'd like to prevent any kind of modification (insert, update, delete) in
> a order (and its lines, and steps) if all the steps in the lines of the
> order are "checked". If that condition is not true, a modification is
> accepted.
>
>
> Does anyone have an idea maybe? The rule system? Thanks for your ideas.

Yes, with RULEs. A simple example to prevent UPDATE for subset rows:

test=# select * from foo;
id | t
----+-----
5 | 1,2
6 | 2,2
7 | 3,2
1 | 1
1 | 1
0 | 10
0 | 10
(7 rows)

test=*# select * from looked ;
id
----
1
(1 row)

-- i want to prevent update for all id's listed in table looked

test=*# create rule r1 as on update to foo where old.id in (select id from looked) do instead nothing;
CREATE RULE
test=*# update foo set t = 100 where id=0;
UPDATE 2
test=*# update foo set t = 100 where id=1;
UPDATE 0
test=*# select * from foo;
id | t
----+-----
5 | 1,2
6 | 2,2
7 | 3,2
1 | 1
1 | 1
0 | 100
0 | 100
(7 rows)

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

Browse pgsql-general by date

  From Date Subject
Next Message Bill Moran 2007-06-19 11:41:17 Re: VACUUM ANALYZE extremely slow
Previous Message Philippe Lang 2007-06-19 10:23:51 How to prevent modifications in a tree of rows, based on a condition?