日期:2014-05-16  浏览次数:20791 次

mysql Not allowed to return a result set from a trigger
今天在学习mysql时,创建触发器总是不成功报这个错Not allowed to return a result set from a trigger;
比如这样创建 create trigger newproduct after insert on products for each row select 'd'; 把

后面的返回结果去掉,还是报错:
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near '' at
line 1
有谁知道原因的,帮帮忙

------解决方案--------------------
DELIMITER $$
CREATE TRIGGER newproduct AFTER INSERT ON products 
FOR EACH ROW 
SELECT 'd' INTO @ee;
$$
DELIMITER ;
------解决方案--------------------
create trigger newproduct after insert on products for each row select 'd';

触发器中不能有这种 select 'd'; 的语句,这个语句会返回结果集。
------解决方案--------------------
DELIMITER //
CREATE TRIGGER newproduct AFTER INSERT ON products 
FOR EACH ROW 
SELECT 'd' INTO @ee;
//
DELIMITER ;

------解决方案--------------------
将$$->//