views:

1344

answers:

1

Is it possible to do something like this:

begin;
    insert into some_table (some_col, another_col) values ('a', 'b');
    insert into some_table (some_col, another_col) values ('c', 'd');
    ...
commit;

...in HTML 5?

With each transaction being async and having it's own callback, seems to me that it would be difficult to write a routine that inserts an unknown amount of rows, and then calls back when it has completed.

+1  A: 

Why yes, yes there is indeed a way to do that!

If you had read the HTML5 Web Database spec, you would know that the executeSql method takes its own callback as a parameter. You would also know that each transaction also has its success and failure callbacks, just like each executeSql call, and that you can have as many executeSql calls in a transaction as you want.

Jani Hartikainen
I'd give you a +1 since you answer the question with a link to the relevant spec, but your answer is a bit snarky. RTFM isn't considered polite on Stack Overflow; sometimes people ask so they can be pointed to the right place in TFM, or to the right FM, if they're not sure what the authoritative manual is, or because they may need a little help interpreting a somewhat terse reference.
Brian Campbell
I actually did read much of the spec, however I could not find the answer. As Brian pointed out, it isn't always obvious. Thanks though!
jarcoal