Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
In our two previous examples we created one trigger that will block deletions from the categories table, instead marking records as inactive, and we created another trigger that when a category is marked as inactive, it marks all products as inactive also. This means that if I issue a DELETE statement, the first trigger fires, blocking my DELETE statement, and instead updating the record. That update, the update that was caused by the trigger, will in turn cause the second trigger to fire.
This situation where the actions of one trigger cause the next trigger to fire is called nested triggers. The ability to nest triggers is turned on by default, but you can turn it off if you want to. I have some code in your exercise files that will do this. It's an SP configure, the feature we would like to configure is nested triggers. It is turned on by default which would be a 1. So we'll use a 0 to turn it off and if you'd like to turn it back on, just use a 1.
Even when nested triggers is turned on, it is always limited to 32 levels. So we can have trigger 1, cause trigger 2 to fire which causes trigger 3 to fire, which causes trigger 4 to fire, but you can only go 32 levels deep. That is at least the machine says, you can only go 32 levels deep. As a best practice I would recommend a lot less than 32 levels. Obviously, something that goes 30 or 31 levels deep could be very difficult to troubleshoot and very difficult to get your mind around what's going on.
As a best practice, I usually try and limit my nesting to three levels or less.
Get unlimited access to all courses for just $25/month.Become a member
82 Video lessons · 98219 Viewers
61 Video lessons · 85533 Viewers
71 Video lessons · 69482 Viewers
56 Video lessons · 101818 Viewers
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.
Your file was successfully uploaded.