Automatic Deletes? - Mailing list pgsql-sql

From Itai Zukerman
Subject Automatic Deletes?
Date
Msg-id E13HpLC-0000lr-00@matt.w80.math-hat.com
Whole thread Raw
List pgsql-sql
Hi,

I have:

CREATE TABLE a ( id SERIAL, val INT4 ) ;

I would like to create some rules to keep "a" free from rows where
val == 0.  Something like:
 CREATE RULE a_insert AS ON INSERT TO a WHERE NEW.val = 0 DO INSTEAD NOTHING ;
 CREATE RULE a_update AS ON UPDATE TO a WHERE NEW.val = 0 DO INSTEAD   DELETE FROM a   WHERE id = NEW.id ;

Does this look right?  I think there should be a better way to express
the second rule...

Thanks,
-itai


pgsql-sql by date:

Previous
From: Itai Zukerman
Date:
Subject: Re: Conditional rule?
Next
From: Tom Lane
Date:
Subject: Re: Conditional rule?