X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id BE893D1B17B for ; Fri, 21 May 2004 06:25:15 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 72621-03 for ; Fri, 21 May 2004 06:24:56 -0300 (ADT) Received: from matrix.gatewaynet.com (matrix.gatewaynet.com [217.19.69.50]) by svr1.postgresql.org (Postfix) with ESMTP id 7D66ED1B182 for ; Fri, 21 May 2004 06:24:53 -0300 (ADT) Received: from matrix.gatewaynet.com (localhost.localdomain [127.0.0.1]) by matrix.gatewaynet.com (8.12.8/8.12.8) with ESMTP id i4L8UZLb006730; Fri, 21 May 2004 11:30:35 +0300 Received: from localhost (achill@localhost) by matrix.gatewaynet.com (8.12.8/8.12.8/Submit) with ESMTP id i4L8UZW0006726; Fri, 21 May 2004 11:30:35 +0300 Date: Fri, 21 May 2004 11:30:35 +0300 (EEST) From: Achilleus Mantzios To: Jeff Post Cc: pgsql-sql@postgresql.org Subject: Re: Preventing Deletions with triggers In-Reply-To: <6.1.0.6.0.20040519090934.025963a8@mail.milwaukee.k12.wi.us> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-new at postgresql.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200405/194 X-Sequence-Number: 17908 O kyrios Jeff Post egrapse stis May 19, 2004 : > I would like to have a trigger that fires whenever a delete is attempted. > The trigger should update the status field of the tupple (to remove the > tupple form the active set of tupples). > A rule would be more appropriate for this task. > > Here is what I got: > > CREATE or replace FUNCTION person_fake_delete() RETURNS TRIGGER AS ' > BEGIN > OLD.status := 1; -- This does the fake deletion > RETURN NULL; -- I thought this would prevent the delete from > actually happening. > END; > ' LANGUAGE 'plpgsql'; > > create trigger person_fake_delete > before delete on person > for each row EXECUTE PROCEDURE > person_fake_delete(); > > This however does not work. the tupple is still deleted from the > table. Any Ideas? > > Thanks, > Jeff Post > > > ---------------------------(end of broadcast)--------------------------- > TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org > -- -Achilleus