[whatwg] Comments on updated SQL API

Ian Hickson ian at hixie.ch
Mon Sep 24 21:07:11 PDT 2007

On Sat, 22 Sep 2007, Maciej Stachowiak wrote:
> Sometimes it's useful to schedule multiple SQL queries in a single 
> transaction at once, without a separate async callback for each. We 
> discussed possible syntax something like the following:
> void executeSql(in sequence<Object> sqlStatements, in SQLMultiCallback
> callback);
> sqlStatements is an Array where each element is either a string or an 
> array. If a string, it is treated as a standalone statement. If an 
> array, it the first element of that nested array is a statement with ? 
> slots for parameter substitution and the remainder of the elements are 
> arrays. SQLMultiCallback is like SQLCallback but gets an array of 
> ResultSets. Example:
> db.executeSql(['INSERT INTO "db1" ("column1") VALUES ("value1")',
>                       ['UPDATE "counter" SET "version" = ? WHERE "version" =
> ?', v + 1, v]],
> function (resultArray) {
>     // ... do stuff ...
> });
> Otherwise, there's no way to put multiple independent statements inside 
> a transaction from top level.

I've not added this to this version of the spec, as it is basically just 
syntactic sugar, and it isn't immediately obvious how to make it easy to 
handle errors in such a scenario.

It would be interesting to see how people use executeSql() with multiple 
statements, to see what we can do to best address there needs.

Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'

More information about the whatwg mailing list