本文介绍了MySQL 错误代码 1235的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 MySQL 中,我尝试定义这样的触发器:

In MySQL I tried to define a trigger like this:

DELIMITER $$
CREATE TRIGGER vipInvite
AFTER INSERT ON meetings
FOR EACH ROW
BEGIN
IF(NOT EXISTS (SELECT * FROM participants
   WHERE meetid = NEW.meetid AND pid ='vip'))
    THEN
    IF(EXISTS(SELECT * FROM meetings WHERE meetid = NEW.meetid AND slot > 16))
    THEN
    INSERT INTO participants(meetid, pid)
    VALUES (NEW.meetid,(SELECT userid
    FROM   people WHERE people.group = 'tap' GROUP BY invite));
END IF;
END IF;
END $$
DELIMITER ;

产生这个错误:

此版本的 MySQL 尚不支持一个表具有相同动作时间和事件的多个触发器.

有没有办法解决这个问题,以便我可以定义多个触发器?

Is there a way to work around this so I can define multiple triggers?

推荐答案

这个错误意味着你已经在 meetings 表上有一个 AFTER INSERT 触发器.

This error means you already have an AFTER INSERT trigger on meetings table.

如果它是你之前创建的同一个触发器(意思是 vipInvite),现在你想替换它,那么你需要先删除它

If it is the same trigger (meaning vipInvite) that you created earlier and now you want to replace it then you need to drop it first

DROP TRIGGER vipInvite;
DELIMITER $$
CREATE TRIGGER vipInvite
...
END$$
DELIMITER ;

现在,如果您有其他触发器,则必须将两个触发器的代码合并为一个,然后删除现有触发器,然后创建一个新触发器.

Now if you have some other trigger you have to merge code from both triggers into one, then drop existing trigger, and then create a new one.

要显示现有触发器的列表,请使用 SHOW触发器.

To show the list of existing triggers use SHOW TRIGGERS.

SHOW TRIGGERS WHERE `table` = 'meetings';

这篇关于MySQL 错误代码 1235的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-13 11:46