Trigger calls in cascade deleting

大憨熊 提交于 2019-11-29 01:08:14
Niel de Wet

From http://dev.mysql.com/doc/refman/5.6/en/innodb-restrictions.html

Cascaded foreign key actions do not activate triggers

In other words, you cannot use the trigger with cascaded deleting.

Also see related bugs:

To summarize the answers from @Niel de Wet and @Browny Lin:

  1. Sadly cascaded deletes do not activate triggers in MySQL.
  2. One solution is to not use cascading deletes but instead implement the automatic delete via another trigger.

Let me share how I've been "fixing" this issue from the first day I discovered it existed. I copy the trigger from the cascaded table into the first table that's deleted directly. It just works.

A lot of times it's a matter of copy/paste, and occasionally it requires extensive re-writing of the code.

The best part is, when Oracle finally fixes this Bug you only have remove the trigger code from the said table. Voila!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!