From: Jeff Post <POSTJL@milwaukee.k12.wi.us>
To: pgsql-sql@postgresql.org
Subject: Preventing Deletions with triggers
Date: Wed, 19 May 2004 09:19:47 -0500
Message-ID: <6.1.0.6.0.20040519090934.025963a8@mail.milwaukee.k12.wi.us> (raw)
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
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-sql@postgresql.org
Cc: POSTJL@milwaukee.k12.wi.us
Subject: Re: Preventing Deletions with triggers
In-Reply-To: <6.1.0.6.0.20040519090934.025963a8@mail.milwaukee.k12.wi.us>
References: <6.1.0.6.0.20040519090934.025963a8@mail.milwaukee.k12.wi.us>
* 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