-
Notifications
You must be signed in to change notification settings - Fork 56
Description
I am using the cordova-sqlite-ext plugin for a mobile app I am developing (iOS and Android). I am running in to a problem where I get this ERROR:
Unable to begin transaction: cannot start a transaction within a transaction.
It's really a bummer. 😞
lol
So i've tried a number of things - and have found lots of doc'n in the readme. Some things I tried:
- Closing the dbase (see Readme > "Close a database object"). For some reason the dbase did not re-open when I switch to the page where the test button is.
- Used a callback to make sure the transaction completed. I had an alert pop up to verify transaction was complete. However, I still got the above error.
So it's still not working. It seems my UPDATE transaction is not committed. Sometimes it works upon first start up of the app, but then it won't commit when I go and try to repeat the update with a new value. That's when I get the above error.
I think it might be because I have kicked off two functions which run at the same time but in different directions.
User clicks a link on page 1. This kicks off two functions at the same time:
Function 1 Does an UPDATE query adding to a record in the dbase. This is a transaction.executeSql inside a db.transaction.
Function 2 Opens a new page and will try to populate a listview with a ...
transaction.executeSql SELECT query.
This is also a transaction.executeSql inside a db.transaction.
It's strange cuz neither the built-in error nor success message shows. I only see page 2 open - showing only the header. For some reason the listview has failed to open. I have other error handlers which also fail to fire.
Then I go to a test page and click a button to verify the changed record in the database. Sometimes the record is updated, sometimes I get the above error msg. If i click OK, then click the same button again, this time it shows the record - and it will not be updated.
I am wondering if Function 2 crashes for some reason and this stops Function 1 from completing?
Is this a common problem?