Search Postgresql Archives

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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux