Description: Exceptions raised by triggers have a statement severity; they roll back the statement that caused the trigger to fire.
Keywords: Triggers, and exceptions, automatic rollback of trigger actions

# Triggers and exceptions

Exceptions raised by triggers have a statement severity; they roll back the statement that caused the trigger to fire.

This rule applies to nested triggers (triggers that are fired by other triggers). If a trigger action raises an exception (and it is not caught), the transaction on the current connection is rolled back to the point before the triggering event. For example, suppose Trigger A causes Trigger B to fire. If Trigger B throws an exception, the current connection is rolled back to the point before the statement in Trigger A that caused Trigger B to fire. Trigger A is then free to catch the exception thrown by Trigger B and continue with its work. If Trigger A does not throw an exception, the statement that caused Trigger A, as well as any work done in Trigger A, continues until the transaction in the current connection is either committed or rolled back. However, if Trigger A does not catch the exception from Trigger B, it is as if Trigger A had thrown the exception. In that case, the statement that caused Trigger A to fire is rolled back, along with any work done by both of the triggers.

- Aborting statements and transactions
  You might want a trigger action to be able to abort the triggering statement or even the entire transaction.

Parent topic: Programming trigger actions
Related concepts
Trigger action overview
Performing referential actions
Accessing before and after rows
Related reference
Examples of trigger actions