-
Notifications
You must be signed in to change notification settings - Fork 667
Compile
agershun edited this page Jan 29, 2015
·
6 revisions
Alasql can precompile statements. It is a kind a "prepare" in other SQL databases.
To compile statement use:
var stmt = alasql.compile(sql)
Then run the statement:
stmt([parameters array], callback)
Here is the example how to calculate sum of numbers > 2 from [1,2,3,4,5]:
var data = [{a:1},{a:2},{a:3},{a:4},{a:5}];
// Compile
var mysum = alasql.compile("SELECT VALUE SUM(a) FROM ? WHERE a > 2");
// Run
var res = mysum([data])
Try this example in jsFiddle
© 2014-2024, Andrey Gershun & Mathias Rangel Wulff
Please help improve the documentation by opening a PR on the wiki repo