Automatic Deletes?

From: Itai Zukerman <zukerman(at)math-hat(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: Automatic Deletes?
Date: 2000-07-27 15:12:54
Message-ID: E13HpLC-0000lr-00@matt.w80.math-hat.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 2000-07-27 15:36:10 Re: Conditional rule?
Previous Message Itai Zukerman 2000-07-27 15:05:35 Re: Conditional rule?