{"action":"opened","issue":{"url":"https://api.github.com/repos/litehelpers/Cordova-sqlite-storage/issues/371","labels_url":"https://api.github.com/repos/litehelpers/Cordova-sqlite-storage/issues/371/labels{/name}","comments_url":"https://api.github.com/repos/litehelpers/Cordova-sqlite-storage/issues/371/comments","events_url":"https://api.github.com/repos/litehelpers/Cordova-sqlite-storage/issues/371/events","html_url":"https://github.com/litehelpers/Cordova-sqlite-storage/issues/371","id":112371165,"number":371,"title":"How to close db when execute an asynchronous transaction?","user":{"login":"bl905060","id":13462495,"avatar_url":"https://avatars.githubusercontent.com/u/13462495?v=3","gravatar_id":"","url":"https://api.github.com/users/bl905060","html_url":"https://github.com/bl905060","followers_url":"https://api.github.com/users/bl905060/followers","following_url":"https://api.github.com/users/bl905060/following{/other_user}","gists_url":"https://api.github.com/users/bl905060/gists{/gist_id}","starred_url":"https://api.github.com/users/bl905060/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bl905060/subscriptions","organizations_url":"https://api.github.com/users/bl905060/orgs","repos_url":"https://api.github.com/users/bl905060/repos","events_url":"https://api.github.com/users/bl905060/events{/privacy}","received_events_url":"https://api.github.com/users/bl905060/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-10-20T13:40:07Z","updated_at":"2015-10-20T13:40:07Z","closed_at":null,"body":"When SQL is finished, I want to close the database, But I can not find the right position to perform close statement.When I put the close statement in insertSuccess function, Xcode will send me an error message. like that: \"cannot close: transaction is in progress\". Otherwise, I put the close statement after errorData function, it will send me another error message : \"closing db with transaction queue length: 1\". \r\n\r\nMy partial code are followed:\r\n\r\n\r\n        mydb.transaction(insertData, errorData);        \r\n        function insertData(tx) {\r\n            console.log(\"sql is ready to run!\");\r\n            for (c=1; c<=tableCount; c++) {\r\n                tx.executeSql(sql[c] + ' VALUES ' + params[c], insertParams[c], insertSuccess, errorData);\r\n            }\r\n        }\r\n        \r\n        function insertSuccess() {\r\n            successCount++;\r\n            if (successCount == tableCount) {\r\n                callback();\r\n                operateDB.closeDB(mydb);\r\n            }\r\n        }\r\n        \r\n        function errorData(err) {\r\n            alert(\"Error processing SQL:\" + err.code);\r\n        }"}}