在下面的MYSQL存储过程中,每当由于数据截断而出现警告时,都会显示警告。但它不会回滚任何东西。WARNING 的 EXIT 处理程序完全被忽略。请帮忙。
DELIMITER $$
DROP PROCEDURE IF EXISTS `saveDetails` $$
CREATE DEFINER=`dbuser`@`%` PROCEDURE `saveDetails`(IN param_name VARCHAR(200))
BEGIN
DECLARE EXIT HANDLER FOR SQLEXCEPTION ROLLBACK;
DECLARE EXIT HANDLER FOR SQLWARNING ROLLBACK;
START TRANSACTION;
UPDATE userDetails SET displaystatus = 2 where displaystatus = 1;
UPDATE userDetails SET displaystatus = 1 where displaystatus = 0;
UPDATE userDetails SET name = param_name;
COMMIT;
END $$
DELIMITER ;
我也尝试了以下版本,但这也不起作用:
分隔符 $$
DROP PROCEDURE IF EXISTS `saveDetails` $$
CREATE DEFINER=`dbuser`@`%` PROCEDURE `saveDetails`(IN param_name VARCHAR(200))
BEGIN
DECLARE EXIT HANDLER FOR SQLEXCEPTION, SQLWARNING
BEGIN
ROLLBACK;
END;
START TRANSACTION;
UPDATE userDetails SET displaystatus = 2 where displaystatus = 1;
UPDATE userDetails SET displaystatus = 1 where displaystatus = 0;
UPDATE userDetails SET name = param_name;
COMMIT;
END $$
DELIMITER ;