Skip to content

Instantly share code, notes, and snippets.

@nisar1
Last active August 29, 2015 13:57
Show Gist options
  • Save nisar1/9567325 to your computer and use it in GitHub Desktop.
Save nisar1/9567325 to your computer and use it in GitHub Desktop.
transaction in sp mysql
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