如何避免这些触发器更新的无限循环递归?

时间:2012-05-16 14:33:05

标签: mysql triggers

我希望有以下3个触发器:

#START TRIGGER
delimiter $$
CREATE TRIGGER `lastedited` AFTER UPDATE ON `eng-jap`
FOR EACH ROW
BEGIN
UPDATE `mrhowtos_main`.`eng` 
SET `english` = new.eng WHERE `english` = old.eng;
UPDATE `mrhowtos_main`.`jap` 
SET `japanese` = new.jap WHERE `japanese` = old.jap;
END;
$$


#START TRIGGER
delimiter $$
CREATE TRIGGER `lastedited2` AFTER UPDATE ON `eng`
FOR EACH ROW
BEGIN
UPDATE `mrhowtos_main`.`eng-jap` 
SET `eng-jap`.`eng` = new.english WHERE `eng-jap`.`eng` = old.english;
END;
$$


#START TRIGGER
delimiter $$
CREATE TRIGGER `lastedited3` AFTER UPDATE ON `jap`
FOR EACH ROW
BEGIN
UPDATE `mrhowtos_main`.`eng-jap` 
SET `eng-jap`.`jap` = new.japanese WHERE `eng-jap`.`jap` = old.japanese;
END;
$$

但在我创建它们之前,我发现只要任何表更新,就会有无限循环的触发器。基本上我不希望触发器UPDATE“触发”其他触发器。我该怎么做?

0 个答案:

没有答案