Re: Preventing Deletions with triggers

From: Achilleus Mantzios <achill(at)matrix(dot)gatewaynet(dot)com>
To: Jeff Post <POSTJL(at)milwaukee(dot)k12(dot)wi(dot)us>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Preventing Deletions with triggers
Date: 2004-05-21 08:30:35
Message-ID: Pine.LNX.4.44.0405211128060.6684-100000@matrix.gatewaynet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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(at)postgresql(dot)org
>

--
-Achilleus

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Richard Huxton 2004-05-21 10:36:54 Re: XML data field
Previous Message Richard Huxton 2004-05-21 08:11:36 Re: v7.2 triggers and foreign keys