SQLite Forum

cannot start a transaction within a transaction using sqlite shell
Login
I'm guessing:

  1.   First window does: `BEGIN; INSERT INTO ...;`

  2.   Second window does `DELETE FROM ...;` with an implicit COMMIT.

  3.   First window tries to do: `END;`.  But because END is just an
       alternative spelling for COMMIT, it cannot, because the second window
       jumped in line ahead of it.  So the COMMIT fails, leaving the
       transaction open.

  4.   All subsequent BEGIN operations fail because there is already
       a transaction open.

Possible solutions:

  *   Use "BEGIN IMMEDIATE" instead of "BEGIN TRANSACTION".

  *   Put the BEGIN and the END on separate input lines.  I think (but I'm not
      sure - I'll need to check the code) that the CLI works a line at a time.
      So if the BEGIN fails, the END never has a chance to run.  Larry has been
      in that code more recently than me → perhaps he can answer off the
      top of his head.