Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySQL Trigger with transaction insert or update

Tags:

mysql

percona

i'm using mysql db & java, so in my application i need to use trigger, but i need to make it save while inserting or updating. when insering new record in table A, trigger will do the work to insert some information in another table B. also when doing update for records in table A, trigger will update records for table B.

if transaction during update or insrt rolledback, does this rolled back any changes done by the trigger.??!!

like image 852
Motasem Avatar asked Nov 20 '25 22:11

Motasem


1 Answers

Yes, if the transaction is rolled back, the work done by the trigger will also be rolled back (unless you do some monkeying with transaction scoping inside the trigger to specifically prevent this)

like image 191
Eric Petroelje Avatar answered Nov 24 '25 05:11

Eric Petroelje



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!