Reputation: 9312
I'm working on an HTML5-based web application that will make use of a local SQL database.
When the app starts up, it needs to do the following (simplified, but roughly correct):
As I understand it, each executeSQL transaction is asynchronous.
In this case - certain steps must be complete before other steps can be executed. In other words, #1 must be complete before anything else can happen. Next, #2, #3, and #4 don't need to be executed serially - but #2 needs to be complete before #5, #3 needs to be complete before #6, etc.
This must be a pretty common challenge. So, what's the best way to code a series of dependent SQL transactions like this?
For what it's worth - this app is targeting iPhones exclusively, so I don't need to worry about browser quirks, or check for the existence of this functionality. But, a cross-browser solution is always preferable.
Many thanks in advance!
Upvotes: 1
Views: 439
Reputation: 691913
executeSql takes a data handler callback function as argument. The data handler function is executed once the query has executed and gives you access to the result set. Just execute the next query in the data handler of the previous query.
Upvotes: 2