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

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 (view raw or flat)
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

pgsql-sql by date

Next:From: Tom LaneDate: 2000-07-27 15:36:10
Subject: Re: Conditional rule?
Previous:From: Itai ZukermanDate: 2000-07-27 15:05:35
Subject: Re: Conditional rule?

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