pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Achilleus Mantzios <achill@matrix.gatewaynet.com>
To: Jeff Post <POSTJL@milwaukee.k12.wi.us>
Cc: pgsql-sql@postgresql.org
Subject: Re: Preventing Deletions with triggers
Date: Fri, 21 May 2004 11:30:35 +0300 (EEST)
Message-ID: <Pine.LNX.4.44.0405211128060.6684-100000@matrix.gatewaynet.com> (raw)
In-Reply-To: <6.1.0.6.0.20040519090934.025963a8@mail.milwaukee.k12.wi.us>

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




view thread (4+ messages)  latest in thread

Message-ID: <Pine.LNX.4.44.0405211128060.6684-100000@matrix.gatewaynet.com>
Permalink:  ../Pine.LNX.4.44.0405211128060.6684-100000@matrix.gatewaynet.com/
Also on:    postgresql.org/message-id/Pine.LNX.4.44.0405211128060.6684-100000@matrix.gatewaynet.com

 · 

reply

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 using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: achill@matrix.gatewaynet.com, POSTJL@milwaukee.k12.wi.us
  Subject: Re: Preventing Deletions with triggers
  In-Reply-To: <Pine.LNX.4.44.0405211128060.6684-100000@matrix.gatewaynet.com>

* 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