pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Itai Zukerman <zukerman@math-hat.com>
To: pgsql-sql@postgresql.org
Subject: Automatic Deletes?
Date: Thu, 27 Jul 2000 11:12:54 -0400
Message-ID: <E13HpLC-0000lr-00@matt.w80.math-hat.com> (raw)

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



Message-ID: <E13HpLC-0000lr-00@matt.w80.math-hat.com>
Permalink:  ../E13HpLC-0000lr-00@matt.w80.math-hat.com/
Also on:    postgresql.org/message-id/E13HpLC-0000lr-00@matt.w80.math-hat.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: zukerman@math-hat.com
  Subject: Re: Automatic Deletes?
  In-Reply-To: <E13HpLC-0000lr-00@matt.w80.math-hat.com>
  References: <E13HpLC-0000lr-00@matt.w80.math-hat.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox