Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ORACLE Rollback and Trigger

Does the after Update trigger will kick off if there is a rollback?

Scenario: Lets say we update a table A and the trigger on table A kicks off and updates another table B with the details. If there is a rollback issued on table A due to some processing error, will the trigger cause the table B to rollback the change?

like image 340
moejoe11 Avatar asked Jul 09 '09 15:07

moejoe11


1 Answers

Yes, it will.

Triggers work in scope of the DML statement's transaction (either started by you explicitly or by the DML statement itself implicitly)

When this transaction is rolled back, all changes made by the triggers are also rolled back.

However, if you put

PRAGMA autonomous_transaction

into the trigger definition, the trigger will start its own transaction which you should commit before the trigger completes.

like image 112
Quassnoi Avatar answered Oct 13 '22 03:10

Quassnoi