Re: trigger : emulate "instead of" with before ?

From: Jeff Eckermann <jeff_eckermann(at)yahoo(dot)com>
To: Albrecht Berger <berger1517(at)gmx(dot)ch>, pgsql <pgsql-sql(at)postgresql(dot)org>
Subject: Re: trigger : emulate "instead of" with before ?
Date: 2003-06-13 13:50:10
Message-ID: 20030613135010.71562.qmail@web20805.mail.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

I believe that if you return NULL from the trigger
function, the delete will not actually be done. You
could set the value of the delete flag by reference to
OLD.fieldname.

I have not actually done this myself, so caveat
emptor.

--- Albrecht Berger <berger1517(at)gmx(dot)ch> wrote:
> 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
>
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/docs/faqs/FAQ.html

__________________________________
Do you Yahoo!?
Yahoo! Calendar - Free online calendar with sync to Outlook(TM).
http://calendar.yahoo.com

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 2003-06-13 13:57:25 Re: trigger : emulate "instead of" with before ?
Previous Message Matthew Nuzum 2003-06-13 13:09:52 Re: trigger : emulate "instead of" with before ?