简体   繁体   中英

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).

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. 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. There is however an archive on Oracle's website, where the documentation for SIGNAL states:

This statement was added in MySQL 6.0.11.

Therefore you will not be able to use SIGNAL with this version of MySQL. 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).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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