W3C home > Mailing lists > Public > whatwg@whatwg.org > September 2007

[whatwg] Comments on updated SQL API

From: Ian Hickson <ian@hixie.ch>
Date: Tue, 25 Sep 2007 04:07:11 +0000 (UTC)
Message-ID: <Pine.LNX.4.62.0709250404130.21662@hixie.dreamhostps.com>
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.   `._.-(,_..'--(,_..'`-.;.'
Received on Monday, 24 September 2007 21:07:11 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:58:57 UTC