MySQL 触发循环
我正在经历整理别人代码的痛苦堆积过程。
因此,我决定重新创建一个新数据库与旧数据库并存,然后使用触发器在两个表之间传输数据。
现在我有一个问题,它循环 IE
每个表上的触发器来更新另一个表。一旦一个更新,它应该更新另一个,但由于两个表都有触发器,它只会循环,这会导致问题。
他们有办法阻止这种情况发生吗?
希望这是有道理的,并希望您能提供建议。
I am going through the pain stacking process of sorting out someone else code.
So I am decided to recreate a new database to sit alongside the old one then to use triggers to transfer data between both tables.
Now I have an issue with a it looping IE
A trigger on each table to update the other. Once one updates it should update the other but as both tables have triggers it just will loop which will cause an issue.
Is their a way to stop this from happening ?
Hope this makes sense and hope you can advise.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该在一个数据库中创建条目并使用触发器将该数据复制到第二个数据库。话虽如此,您使用检查数据是否存在并退出触发器。基本上,如果记录存在,则不执行任何操作。这个网站有一个很好的教程:
http://www.databasedesign-resource.com/mysql -triggers.html
您可能还想阅读 mySQL 手册中的触发器:
http://dev.mysql.com/doc/refman/5.0/en/triggers.hthl
You should be making entries in one db and using the trigger to copy that data to the second db. Having said that you use a check for the existence of the data and exit the trigger. Basically an if record exist do nothing. This site has a good tutorial:
http://www.databasedesign-resource.com/mysql-triggers.html
You may aloso want to read up on triggers in the mySQL manual:
http://dev.mysql.com/doc/refman/5.0/en/triggers.hthl