MySQL - How to check if START TRANSACTION is active

前端 未结 2 1910
鱼传尺愫
鱼传尺愫 2021-01-11 17:03

I have noticed that START TRANSACTION automatically COMMIT the previous queries. Because of this and the fact that I have several stored procedure

2条回答
  •  借酒劲吻你
    2021-01-11 17:43

    From https://dev.mysql.com/doc/refman/5.5/en/implicit-commit.html:

    Transactions cannot be nested. This is a consequence of the implicit commit performed for any current transaction when you issue a START TRANSACTION statement or one of its synonyms.

    I suspect that the problem can be solved by using SET autocommit=0; instead of START TRANSACTION;. If autocommit is already 0, it will have no effect.

    See also Does setting autocommit=0 within a transaction do anything?

提交回复
热议问题