Thanks @kordirko. I have get one solution with RESIGNAL. But it is only supported until MySQL 5.5.
DECLARE EXIT HANDLER FOR SQLEXCEPTION
BEGIN
SET @flag = 1;
IF @flag = 1 THEN RESIGNAL;END IF;
ROLLBACK;
END;
Question
MySQL stored procedure will throw the error out if there is no rollback
command for SQLEXCEPTION
, but it has changed some data before the exception.
I add rollback command for SQL exceptions:
DECLARE EXIT HANDLER FOR SQLEXCEPTION
BEGIN
ROLLBACK;
END;
But I can not know the reason of the rollback now.
I know we can define every SQL exception and it's handler, but it's too complex and I just want to know why the rollback occurred.
Is there a simple method to get the reason of rollback in MySQL stored procedure?
Solution
Thanks @kordirko. I have get one solution with RESIGNAL. But it is only supported until MySQL 5.5.
DECLARE EXIT HANDLER FOR SQLEXCEPTION
BEGIN
SET @flag = 1;
IF @flag = 1 THEN RESIGNAL;END IF;
ROLLBACK;
END;