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 8F727D1B25F for ; Wed, 19 May 2004 11:20:07 -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 31956-06 for ; Wed, 19 May 2004 11:19:49 -0300 (ADT) Received: from mailgw.milwaukee.k12.wi.us (mailgw.milwaukee.k12.wi.us [169.227.254.71]) by svr1.postgresql.org (Postfix) with SMTP id 4F678D1B23C for ; Wed, 19 May 2004 11:19:44 -0300 (ADT) Received: from mail.milwaukee.k12.wi.us ([169.227.1.5]) by mailgw.milwaukee.k12.wi.us (SAVSMTP 3.1.1.32) with SMTP id M2004051909210219326 for ; Wed, 19 May 2004 09:21:02 -0500 Received: from 012-122-JEFF.mail.milwaukee.k12.wi.us ([10.60.7.159]) by mail.milwaukee.k12.wi.us (8.8.5/8.6.9) with ESMTP id JAA08589 for ; Wed, 19 May 2004 09:19:47 -0500 (CDT) Message-Id: <6.1.0.6.0.20040519090934.025963a8@mail.milwaukee.k12.wi.us> X-Mailer: QUALCOMM Windows Eudora Version 6.1.0.6 Date: Wed, 19 May 2004 09:19:47 -0500 To: pgsql-sql@postgresql.org From: Jeff Post Subject: Preventing Deletions with triggers Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; format=flowed 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/187 X-Sequence-Number: 17902 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). 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