Created
September 20, 2015 19:41
-
-
Save EliuTimana/b5635cf76b39077980fb to your computer and use it in GitHub Desktop.
This file contains hidden or 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
DELIMITER $$ | |
CREATE PROCEDURE sp_fail() | |
BEGIN | |
DECLARE _rollback BOOL DEFAULT 0; | |
DECLARE CONTINUE HANDLER FOR SQLEXCEPTION SET _rollback = 1; | |
START TRANSACTION; | |
INSERT INTO tablea (date) VALUES (NOW()); | |
INSERT INTO tableb (date) VALUES (NOW()); | |
INSERT INTO tablec (date) VALUES (NOW()); -- FAIL | |
IF _rollback THEN | |
ROLLBACK; | |
ELSE | |
COMMIT; | |
END IF; | |
END; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment