pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Nick Johnson <arachnid@notdot.net>
To: PostgreSQL SQL <pgsql-sql@postgresql.org>
Subject: Re: preventing deletion of a row
Date: Tue, 07 Jun 2005 17:59:18 +1200
Message-ID: <42A537B6.8040902@notdot.net> (raw)
In-Reply-To: <200506071059.17689.lawgon@thenilgiris.com>
References: <200506071059.17689.lawgon@thenilgiris.com>

Kenneth Gonsalves wrote:

>hi
>i have a table of the type:
>
>id serial unique,
>name varchar(50),
>fixed boolean default FALSE
>
>if the value of 'fixed' is TRUE, then this row cannot be deleted. How 
>do i enforce this condition?
>  
>
Try this:
CREATE RULE tablename_delete AS ON DELETE TO tablename WHERE OLD.fixed = 
TRUE DO INSTEAD NOTHING;

-Nick Johnson



view thread (3+ messages)  latest in thread

Message-ID: <42A537B6.8040902@notdot.net>
Permalink:  ../42A537B6.8040902@notdot.net/
Also on:    postgresql.org/message-id/42A537B6.8040902@notdot.net

 · 

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 using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: arachnid@notdot.net
  Subject: Re: preventing deletion of a row
  In-Reply-To: <42A537B6.8040902@notdot.net>

* 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