X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id DFE6152879 for ; Tue, 7 Jun 2005 02:56:59 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 31421-02 for ; Tue, 7 Jun 2005 05:56:51 +0000 (GMT) Received: from linda-2.paradise.net.nz (bm-2a.paradise.net.nz [202.0.58.21]) by svr1.postgresql.org (Postfix) with ESMTP id 072B552849 for ; Tue, 7 Jun 2005 02:56:48 -0300 (ADT) Received: from smtp-1.paradise.net.nz (smtp-1a.paradise.net.nz [202.0.32.194]) by linda-2.paradise.net.nz (Paradise.net.nz) with ESMTP id <0IHP00GK99UMHV@linda-2.paradise.net.nz> for pgsql-sql@postgresql.org; Tue, 07 Jun 2005 17:56:47 +1200 (NZST) Received: from [192.168.1.50] (203-79-75-147.paradise.net.nz [203.79.75.147]) by smtp-1.paradise.net.nz (Postfix) with ESMTP id B7F9882FF4 for ; Tue, 07 Jun 2005 17:56:13 +1200 (NZST) Date: Tue, 07 Jun 2005 17:59:18 +1200 From: Nick Johnson Subject: Re: preventing deletion of a row In-reply-to: <200506071059.17689.lawgon@thenilgiris.com> To: PostgreSQL SQL Message-id: <42A537B6.8040902@notdot.net> MIME-version: 1.0 Content-type: text/plain; format=flowed; charset=UTF-8 Content-transfer-encoding: 7bit X-Accept-Language: en-us, en User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) References: <200506071059.17689.lawgon@thenilgiris.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.458 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200506/93 X-Sequence-Number: 21694 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