今天在学习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
有谁知道原因的,帮帮忙

解决方案 »

  1.   

    就是执行sql语句时出的这个错,我的mysql是5.0的
      

  2.   

    create trigger newproduct after insert on products for each row select 'd';
    就是这句啊
      

  3.   

    已经提示,在TRIGGER中不能返回结果集
      

  4.   

    文章中我已经写过了,去掉结果,还是会有错的: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
      

  5.   

    DELIMITER $$
    CREATE TRIGGER newproduct AFTER INSERT ON products 
    FOR EACH ROW 
    SELECT 'd' INTO @ee;
    $$
    DELIMITER ;
      

  6.   

    create trigger newproduct after insert on products for each row select 'd';触发器中不能有这种  select 'd'; 的语句,这个语句会返回结果集。
      

  7.   

    已经提示了啊。触发器中不能返回记录集。MYSQL就是这么规定的,没什么好说的。
      

  8.   

    这样写是对了,但对于不要返回结果的还是出错: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
    为啥我用//代替不行呢,非得用$$符号才行么?能给个解释么?谢谢
      

  9.   

    DELIMITER //
    CREATE TRIGGER newproduct AFTER INSERT ON products 
    FOR EACH ROW 
    SELECT 'd' INTO @ee;
    //
    DELIMITER ;