Best way to code a large amount of DML from triggers
I require a large amount of DML to be executed from a number of triggers. Is it a good idea for each trigger to call a private pr开发者_如何学Goocedure to do this?
Having a large amount of logic in a trigger is generally a bad idea because it makes understanding the system and tracing the data flow exceptionally difficult. You're far better served having APIs (i.e. stored procedures) that do the DML operation and then do the logic that would otherwise be fired from the trigger. That at least consolidates the logic.
If that level of refactoring is not possible, having each trigger call a procedure (standalone or in a package) that does the actual manipulation (calling other functions and procedures as appropriate, of course) is the most efficient way to handle logic in triggers.
精彩评论