trigger : emulate "instead of" with before ?

From: "Albrecht Berger" <berger1517(at)gmx(dot)ch>
To: "pgsql" <pgsql-sql(at)postgresql(dot)org>
Subject: trigger : emulate "instead of" with before ?
Date: 2003-06-13 11:50:54
Message-ID: 046801c331a2$0c483e70$a07ba8c0@wxp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hello,
I need a trigger which is updating a delete flag of a row instead of
deleting it physically.

How do I implement a trigger which doesn't execute a delete without raising
an exception
in plsql ?

CREATE TRIGGER trigger1 BEFORE DELETE ON table1
FOR EACH ROW EXECUTE PROCEDURE setDeleteFlag ();

If I use
RAISE EXCEPTION "..."
the delete statement isn't executed, but I think the transaction is rolled
back too, am I right ?

So what is the best way to implement something (Oracle like) like that :
CREATE TRIGGER trigger1 INSTEAD OF DELETE ON table1
FOR EACH ROW EXECUTE PROCEDURE setDeleteFlag ();

thx

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message javier garcia - CEBAS 2003-06-13 11:59:50 "No such attribute or function 'oid'"
Previous Message javier garcia - CEBAS 2003-06-13 11:44:09 date question