-1

I am getting the following error when using fmdb with iOS. What does this mean?

Error calling sqlite3_step (1: cannot start a transaction within a transaction) SQLITE_ERROR DB Query: begin exclusive transaction Unknown error finalizing or resetting statement (1: cannot start a transaction within a transaction) DB Query: begin exclusive transaction

Anthon
  • 69,918
  • 32
  • 186
  • 246

2 Answers2

1

Look for nested calls to FMDatabase method beginTransaction and/or manually executing the BEGIN TRANSACTION SQL. Or, if using FMDatabaseQueue, look for situations where you might call inTransaction from within another inTransaction block.

Alternatively, if you're manually calling beginTransaction and/or performing BEGIN TRANSACTION, make sure that's offset by a balancing commit/rollback or executing a COMMIT/END/ROLLBACK SQL. This is the benefit of using FMDatabaseQueue method inTransaction, because you know you cannot accidentally neglect to end the transaction.

Bottom line, make sure you don't begin one transaction without ending the prior one. If you're not finding it, put breakpoints/log statements everywhere you enter a transaction and everywhere you exit a transaction, and the problem should become apparent quickly.

Rob
  • 415,655
  • 72
  • 787
  • 1,044
0

It's hard to say for sure what is going wrong without seeing what calls you are making to fmdb, but it sounds like you are making a call to inTransaction from within an existing inTransaction block. This isn't allowed and should never really need to happen, just make all your updates from the first transaction block.

bfich
  • 393
  • 2
  • 19