MySQL 错误代码 1235
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19016297/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
MySQL error code 1235
提问by user2817052
In MySQL I tried to define a trigger like this:
在 MySQL 中,我尝试定义这样的触发器:
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 ;
Produces this error:
产生这个错误:
This version of MySQL doesn't yet support 'multiple triggers with the same action time and event for one table.
此版本的 MySQL 尚不支持“对一个表具有相同操作时间和事件的多个触发器”。
Is there a way to work around this so I can define multiple triggers?
有没有办法解决这个问题,以便我可以定义多个触发器?
回答by peterm
This error means you already have an AFTER INSERT
trigger on meetings
table.
此错误意味着您已经AFTER INSERT
在meetings
表上有一个触发器。
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
如果它与vipInvite
您之前创建的触发器(含义)相同,现在您想替换它,那么您需要先删除它
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.
现在,如果您有其他触发器,则必须将两个触发器的代码合并为一个,然后删除现有触发器,然后创建一个新触发器。
To show the list of existing triggers use SHOW TRIGGERS
.
要显示现有触发器的列表,请使用SHOW TRIGGERS
.
SHOW TRIGGERS WHERE `table` = 'meetings';
回答by Eric Leschinski
How to reproduce this error in MySQL:
如何在 MySQL 中重现此错误:
ERROR 1235 (42000): This version of MySQL doesn't yet support 'multiple
triggers with the same action time and event for one table'
Run the following queries:
运行以下查询:
DELIMITER //
CREATE TRIGGER mytrigger1 AFTER INSERT ON mytable
FOR EACH ROW
BEGIN
END//
DELIMITER //
CREATE TRIGGER mytrigger2 AFTER INSERT ON mytable
FOR EACH ROW
BEGIN
END//
If you want to hook more than one action onto the same event/table, you will have to cram all of it into one trigger. You could call many stored procedures like this:
如果您想将多个操作挂接到同一个事件/表上,则必须将所有操作都塞进一个触发器中。您可以像这样调用许多存储过程:
DELIMITER //
CREATE TRIGGER mytrigger1 AFTER INSERT ON mytable
FOR EACH ROW
BEGIN
CALL fromulate_the_moobars(NEW.myid);
CALL its_peanut_butter_jelly_time(NEW.myname);
END//