How to execute multiple statements in Web SQL?

Is there a way to execute multiple statements in a single transaction? I want to do something like:

db.transaction(function (tx) { tx.executeSql( "CREATE TABLE Foo(ID INTEGER); CREATE TABLE Bar(ID INTEGER)", function (tx, result) { alert("success!"); }); }); 

But instead, I found that I should do something like this:

 db.transaction(function (tx) { tx.executeSql("CREATE TABLE Foo(ID INTEGER)"); tx.executeSql("CREATE TABLE Bar(ID INTEGER)", function (tx, result) { alert("success!"); }); }); 

Am I limited to executing individual statements in their own transaction and then failing in a successful Fn transaction in the last transaction, or is there a way I can execute multiple statements in a single transaction?

+7
source share
1 answer

The second code already executes several statements in one transaction. The first code is incorrect (not supported), because it is not clear what result the callback returns.

Even if supported, the performance will be the same as internally, it must be converted to a second statement.

+7
source

All Articles