在 mysql 错误 1064 中创建触发器时出现问题? [英] problem while creating a trigger in mysql error 1064?

查看:122
本文介绍了在 mysql 错误 1064 中创建触发器时出现问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 mysql 中创建触发器时遇到问题:

错误SQL查询:

CREATE TRIGGER product_after_insert插入后每行水果开始插入产品( 类别,产品编号)价值观( '水果',新.ID)

<块引用>

MySQL 说:文档1064 - 你的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册以了解要使用的正确语法在第 11 行的 '' 附近

解决方案

请找到带有关于错误的内联注释的固定触发器:

-- 需要将 DELIMITER 定义为除 ; 以外的其他内容.分隔符 $$创建触发器 product_after_insert插入后每行水果开始插入产品(类别,产品编号)价值观('水果',新.ID);-- ;缺少语句执行END $$ -- 结束 Begin 子句分隔符;-- 将分隔符重新定义为 ;

I have a problem when creating trigger in mysql :

Error SQL query:

CREATE TRIGGER product_after_insert
AFTER INSERT
   ON FRUITS FOR EACH ROW

BEGIN
      INSERT INTO products
   ( category,
     product_id)
   VALUES
   ( 'fruit',
     New.ID)

MySQL said: Documentation 1064 - 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 11

解决方案

Please find the fixed Trigger with inline comments about errors:

-- need to define DELIMITER to something else other than ;
DELIMITER $$

CREATE TRIGGER product_after_insert
AFTER INSERT
   ON FRUITS FOR EACH ROW

BEGIN
      INSERT INTO products
      (category,
       product_id)
      VALUES
      ('fruit',
        New.ID); -- ; was missing for statement execution

END $$  -- End the Begin clause

DELIMITER ;  -- Redefine the delimiter back to ;

这篇关于在 mysql 错误 1064 中创建触发器时出现问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆