MySQL Forums
Forum List  »  InnoDB

Handler for rolling back transactions within a proc
Posted by: Jon Vance
Date: April 15, 2008 10:09PM

I have created the following procedure as a test case for rolling back transactions using exception handlers. The table "Orders" does exist, and the table "DoesNotExist," shockingly, does not. This drop statement is in there simply to force an error. When I call this procedure, the Orders table is cleared, even though there clearly is an error occurring AND being caught by the handler. Can anyone tell me what I'm missing?

DELIMITER ~

CREATE PROCEDURE TEMP() MODIFIES SQL DATA
BEGIN

DECLARE EXIT HANDLER FOR SQLEXCEPTION,SQLWARNING,NOT FOUND
ROLLBACK;

START TRANSACTION;

DELETE FROM Orders;
DROP TABLE DoesNotExist;

COMMIT;

END~

Options: ReplyQuote


Subject
Views
Written By
Posted
Handler for rolling back transactions within a proc
3800
April 15, 2008 10:09PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.