Re: preventing deletion of a row

From: Nick Johnson <arachnid(at)notdot(dot)net>
To: PostgreSQL SQL <pgsql-sql(at)postgresql(dot)org>
Subject: Re: preventing deletion of a row
Date: 2005-06-07 05:59:18
Message-ID: 42A537B6.8040902@notdot.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Vadivel Subramaniam 2005-06-07 06:20:16 large object support in PostGres 7.4
Previous Message Kenneth Gonsalves 2005-06-07 05:31:49 datestyle syntax