How can I use transactions in my MySQL stored procedure?

前端 未结 3 474
甜味超标
甜味超标 2020-11-30 01:25

I\'m trying to modify my MySQL stored procedure and make it transactional. The existing stored procedure works fine with no problem but as soon as I make it transactional it

3条回答
  •  半阙折子戏
    2020-11-30 02:06

    Two syntax errors:

    • You need commas in between the conditions for your exit handler. Notice the syntax documentation shows commas.

    • You need to terminate the END of the exit handler with a semicolon. The DECLARE statement itself (including its BEGIN...END block) is a statement like any other, and need to have a terminator.

    So you need this:

    DECLARE EXIT HANDLER FOR SQLEXCEPTION, SQLWARNING
    BEGIN
        ROLLBACK;
    END;
    

提交回复
热议问题