简体   繁体   English

获取错误代码:创建触发器时出现1064

[英]Getting Error code: 1064 while creating trigger

I am creating trigger but it shows me following error : 我正在创建触发器,但显示以下错误:

        15:22:44    create trigger trigger3 before update on test.testdata    
    for each row  
    begin      
    if new.qty < 50 then         
    SIGNAL SQLSTATE VALUE '99999'       
    SET MESSAGE_TEXT = 'An error occurred';       
    end if;    
    end;    
    Error Code: 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 'SQLSTATE VALUE '99999'       
SET MESSAGE_TEXT = 'An error occurred';       
end i' at line 8    0.000 sec

my trigger code is : 我的触发代码是:

delimiter //

create trigger trigger3 before update on test.testdata

for each row 
begin

if new.qty < 50 then

    SIGNAL SQLSTATE VALUE '99999'
      SET MESSAGE_TEXT = 'An error occurred';

end if;

end;

//
delimiter ;

在此处输入图片说明

The MySQL 6.0 line was discontinued in 2009 (and never hit a production-level release). MySQL 6.0系列已于2009停产 (从未达到生产级别的发布)。

Version 6.0.0-alpha-community-nt-debug , as the name suggests, was a debug build of an alpha release—as such, it really was intended for contributors to the MySQL project to perform early stage testing of the new version. 顾名思义,版本6.0.0-alpha-community-nt-debug是Alpha发行版的调试版本,因此,它实际上是供MySQL项目的贡献者执行新版本的早期测试。 It certainly should not be used in a production system. 这当然应该在生产系统中使用。 Where on Earth did you come upon it? 您是从哪里来的?

Finding documentation for v6.0 is somewhat difficult, since it was long ago removed from the MySQL website. 查找v6.0的文档有些困难,因为它早已从MySQL网站上删除了。 There is however an archive on Oracle's website, where the documentation for SIGNAL states: 但是,Oracle网站上有一个档案SIGNAL的文档中指出:

This statement was added in MySQL 6.0.11. 该语句是在MySQL 6.0.11中添加的。

Therefore you will not be able to use SIGNAL with this version of MySQL. 因此,您将无法在此版本的MySQL上使用SIGNAL If you need to throw an error, you can execute a deliberately erroneous statement, such as calling a non-existent procedure: 如果需要引发错误,则可以执行故意错误的语句,例如调用不存在的过程:

CALL error();

However, if it wasn't obvious from what has been said above, you really should upgrade to a stable production-ready ("general release") version of MySQL server—such as v5.6.14 (which, despite the lower version number, is actually a much more recent release). 但是,如果从上述内容来看并不清楚,那么您确实应该升级到稳定的生产就绪(“通用发行版”)MySQL服务器版本,例如v5.6.14(尽管版本号较低,实际上是最新版本)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM