Sunday 31 March 2013

Why we cannot use commit in a trigger.

1) Trigger is a part of larger transaction, mean it is called by a parent transaction.
2) For instance we used a commit in trigger (child transaction), and processed a transaction,but parent transaction got into error for some reason still the data will be commited in child because of the commit statement.
3) This may mislead the expectation, So it is not suggested to use the commit in triggers because of the parent and child transaction relationship.
4) But if you are OK with the result then by using AUTONOMOUS_TRANSATION, commit can be used.
5) The usage may hurt if properly not used.

No comments:

Post a Comment