I'm using mysql v5.1.48 and red http://dev.mysql.com/doc/refman/5.5/en/signal.html. But the code
DELIMITER $$
CREATE PROCEDURE `CoreRaiseError`()
BEGIN
SIGNAL SQLSTATE '45000'
SET MESSAGE_TEXT = 'An error occurred', MYSQL_ERRNO = 1001;
END$$
raise an
SQL Error 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 '45000'
From which version SIGNAL start to be a keyword? How can I raise an exception with prior version of mysql?
Thank you.
As stated in the manual for MySQL version 5.1:
Other statements related to conditions are
SIGNAL
,RESIGNAL
, andGET DIAGNOSTICS
. TheSIGNAL
andRESIGNAL
statements are not supported until MySQL 5.5. TheGET DIAGNOSTICS
statement is not supported until MySQL 5.6.
To raise an error in older versions of MySQL, just deliberately issue an erroneous command. I often CALL
a non-existent procedure, for example:
CALL raise_error;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With