Last active
August 29, 2015 13:57
-
-
Save nisar1/9567325 to your computer and use it in GitHub Desktop.
transaction in sp mysql
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 `transaction_sp` () | |
BEGIN | |
DECLARE exit handler for sqlexception | |
BEGIN | |
-- ERROR | |
ROLLBACK; | |
END; | |
DECLARE exit handler for sqlwarning | |
BEGIN | |
-- WARNING | |
ROLLBACK; | |
END; | |
START TRANSACTION; | |
INSERT INTO table_name (id, name, address) values ('1','Avinash','xpertdeveloper.com'); | |
UPDATE second_table set name="xyz" where id=4; | |
COMMIT; | |
END | |
$$ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment