Created
August 10, 2020 11:10
-
-
Save wallyhall/51cf26b2c7175c9b2cb68bd4ec78310e to your computer and use it in GitHub Desktop.
MySQL resignal and customised error message
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DECLARE EXIT HANDLER FOR SQLEXCEPTION | |
BEGIN | |
DECLARE v_error_message VARCHAR(512); | |
DECLARE v_condition_number INT(1) UNSIGNED; | |
ROLLBACK; | |
GET DIAGNOSTICS v_condition_number = NUMBER; | |
GET DIAGNOSTICS CONDITION v_condition_number v_error_message = MESSAGE_TEXT; | |
SET v_error_message = CONCAT('Rolledback due to: "', v_error_message, '"'); | |
RESIGNAL SET MESSAGE_TEXT = v_error_message; | |
END; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment