Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What if a trigger fails?

Tags:

mysql

triggers

If I run an insert query, but I have a trigger on a table to increment another value based upon the trigger, but there's something wrong with the trigger, will it still execute my query?

like image 418
Webnet Avatar asked Nov 22 '10 19:11

Webnet


1 Answers

The following reference article should help. Basically, an error during either a BEFORE or AFTER trigger results in failure of the entire statement that caused trigger invocation.

You shouldn't need to test this out, but if you wanted to quickly test this out, simple create a dummy table with a failed insert trigger. The results would be very clear from there.

Hope I helped

like image 85
Salman Paracha Avatar answered Oct 05 '22 23:10

Salman Paracha