From: | "Matthew Nuzum" <cobalt(at)bearfruit(dot)org> |
---|---|
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:09:52 |
Message-ID: | 001501c331ad$14207300$a322fea9@mattspc |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
I'm not a postgres expert, and I certainly don't know the details of your
situation, but it seems to me you may want to use a rule instead of a
trigger.
Then, you can intercept the delete query and simply re-write it to be an
update query that sets your deleted flag.
--
Matthew Nuzum
www.bearfruit.org
cobalt(at)bearfruit(dot)org
> -----Original Message-----
> From: pgsql-sql-owner(at)postgresql(dot)org [mailto:pgsql-sql-
> owner(at)postgresql(dot)org] On Behalf Of Albrecht Berger
> Sent: Friday, June 13, 2003 7:51 AM
> To: pgsql
> Subject: [SQL] trigger : emulate "instead of" with before ?
>
> 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
From | Date | Subject | |
---|---|---|---|
Next Message | Jeff Eckermann | 2003-06-13 13:50:10 | Re: trigger : emulate "instead of" with before ? |
Previous Message | javier garcia - CEBAS | 2003-06-13 11:59:50 | "No such attribute or function 'oid'" |