How to you pass variables into a web sql limit clause?
Posted: Wed Jul 23, 2014 6:13 pm
I'm using web sql to store and retrieve data to and from a mobile device's local memory. I wrote the following query for the retrieval part which works just fine
But I want to use variables in place of the numbers because the code will be reused in several different instances. So my new code reads like this
Unfortunately, this doesn't work and I don't even get any errors. Who knows what I'm doing wrong? :whistling:
Code: Select all
var sql = "SELECT * FROM messages ORDER BY timestamp DESC LIMIT 0,20";
transaction.executeSql (sql, undefined, function (transaction, result){
//Get rows
});
But I want to use variables in place of the numbers because the code will be reused in several different instances. So my new code reads like this
Code: Select all
var index = 0;
var lim = 20;
var sql = "SELECT * FROM messages ORDER BY timestamp DESC LIMIT index,lim";
transaction.executeSql (sql, undefined, function (transaction, result){
//Get rows
});
Unfortunately, this doesn't work and I don't even get any errors. Who knows what I'm doing wrong? :whistling: