Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Better one big trigger or many small?

Re: Better one big trigger or many small?

From: Jonathan Lewis <jonathan_at_jlcomp.demon.co.uk>
Date: Sat, 2 Mar 2002 18:54:08 -0000
Message-ID: <1015096291.24538.0.nnrp-01.9e984b29@news.demon.co.uk>

I can't help feeling that the other posters may be reading your question in a way that you weren't intending.

I read this as:

    if I have a before insert, before update, and     before delete requirement, should I have one or     three triggers.
NOT as

    if I have three separate before insert requirements     should I have one trigger or three triggers.

If your intention was the latter, then the argument that the order of firing of multiple triggers of the same type is the clinching argument - you MUST, as everyone else has pointed out. have a single before insert trigger.

If your intention was the former, then I would advise the general rule that each class of trigger be kept separate. I haven't tested in detail what the performance impact may be, but if you have just the single trigger to cover before insert, before update and before delete, then it MUST fire, and then you have to have code to determine which event (insert, update, or delete) is occurring.

--
Jonathan Lewis
http://www.jlcomp.demon.co.uk

Now running 3-day intensive seminars
http://www.jlcomp.demon.co.uk/seminar.html

Host to The Co-Operative Oracle Users' FAQ
http://www.jlcomp.demon.co.uk/faq/ind_faq.html

Author of:
Practical Oracle 8i: Building Efficient Databases


Carlos wrote in message <1de5ebe7.0202260329.624b085b_at_posting.google.com>...

>I am wondering about the benefits of creating one big trigger (i.e.
>AFTER INSERT, UPDATE OR DELETE) instead of creating many small
>triggers ( AFTER INSERT, AFTER INSERT, AFTER DELETE) per table.
>I think the performance will be better with the three small ones, but
>I'm not sure.
>Another side to concern is the amount of triggers (three or more per
>table), with the complications of maintenance for all of them.
>
>Advices will be appreciated.
>
>Thanks & regards from Spain.
Received on Sat Mar 02 2002 - 12:54:08 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US