/第一段执行没问题/
CREATE TABLE test.t (sl INT,PRIMARY KEY (sl));
DELIMITER //
/第二段执行报错,/
CREATE PROCEDURE handlerdemo ()
BEGIN
DECLARE CONTINUE HANDLER FOR SQLSTATE '23000' SET @x2 = 1;
SET @x = 1;
INSERT INTO test.t VALUES (1);
SET @x = 2;
INSERT INTO test.t VALUES (1);
SET @x = 3;
END;
//
ps:报错
错误代码: 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 3
查询:set @x = 1
共 0 行受到影响
查询:insert into test.t values (1)
错误代码: 1062
Duplicate entry '1' for key 'PRIMARY'
查询:set @x = 2
共 0 行受到影响
查询:insert into test.t values (1)
错误代码: 1062
Duplicate entry '1' for key 'PRIMARY'
查询:set @x = 3
共 0 行受到影响
查询:end
错误代码: 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 'end' at line 1
查询://
错误代码: 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 1
执行耗时 : 0 sec
传送时间 : 0 sec
总耗时 : 0.037 sec
你的 SQL 语法有错误; 检查与您的 MySQL 服务器版本相对应的手册,以获取在第 3 行的 '' 附近使用的正确语法
这个我知道,mysql5.7版本的,按理说 都没问题。