Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Triggers seem to be compiled only randomly
Andreas Mosmann wrote:
> sybrandb_at_yahoo.com schrieb am 03.08.2005 in
> <1123073301.857294.207460_at_o13g2000cwo.googlegroups.com>:
>
>> As to multiple triggers >> 1 Oracle doesn't guarantee the order of the triggers. This may be >> irrelevant in your case, but you'd better not create >> F(ear)U(ncertainty) and D(oubt) in your system.
>> 2 There is a concern with respect to this design. You state the trigger >> concerns a cascading update. I would like to be sure whether the >> cascading update fully succeeded or not. In your case either trigger >> can fail. No harm done when the first trigger fails, but Oracle won't >> roll back the results of the first trigger if the second fails (as >> Oracle has *statement* level rollback by default). So in combination >> with the first issue, you can never be sure which part failed, when you >> have a failure.
>> So the entire thing would need to go into one trigger like this
>> CREATE TRIGGER SABISDAT.itzVerarbeitungsSchlUC0 >> after update of id -- I deliberately changed this
>> ON SABISDAT.tzVerarbeitungsSchl >> ^^^^^^^^^ >> FOR EACH ROW >> BEGIN >> UPDATE >> tbBuchungen >> SET >> cIDVerarb = :NEW.cID >> WHERE >> cIDVerarb = :OLD.cID;
>> UPDATE >> tbBuchungsVorlagen >> SET >> cIDVerarb = :NEW.cID >> WHERE >> cIDVerarb = :OLD.cID; >> exception >> when others then >> rollback; -- roll back the transaction >> raise; -- reraise the error to end-user >> END;
>> The trigger needs to be an after update trigger, because the master >> update may fail.
By the time the triggers have fired, consistency can be checked. Look up deferred foreign key constraints (initially deferred). The database can handle on cascade delete foreign keys (but no cascade updates), so there's no worry, either.
-- Regards, Frank van BortelReceived on Wed Aug 03 2005 - 14:51:52 CDT