I’m trying to create a db using SQLITE on phone gap[cordova 1.7.0] with IOS5. When I increase the number of data, the query fails & outputs an error. I followed the storage API steps, so I don’t know what is the problem. I tried to increase the database size, but it still didn’t work.
This is my code:
function populateDB(tx) {
tx.executeSql('DROP TABLE IF EXISTS SESSION');
tx.executeSql('CREATE TABLE IF NOT EXISTS SESSION (id unique, dayId, subject, Seq)');
tx.executeSql('INSERT INTO SESSION (id unique, dayId, subject, Seq) VALUES (1, 4, "English", 1)');
tx.executeSql('INSERT INTO SESSION (id unique, dayId, subject, Seq) VALUES (2, 1, "Math", 3)');
tx.executeSql('INSERT INTO SESSION (id unique, dayId, subject, Seq) VALUES (3, 2, "Social", 5)');
tx.executeSql('INSERT INTO SESSION (id unique, dayId, subject, Seq) VALUES (4, 6, "Science", 7)');
console.log('finished filling');
}
function queryDB(tx) {
tx.executeSql('SELECT * FROM SESSION', [], querySuccess, errorCB); //It doesn't come here
}
function querySuccess(tx, results) {
// Doesn't come here too
var len = results.rows.length;
console.log("DEMO table: " + len + " rows found.");
for (var i=0; i<len; i++){
console.log("Row = " + i + " ID = " + results.rows.item(i).id + " Data = " + results.rows.item(i).dayId);
}
}
function errorCB(err) {
console.log('error x'); //Fails here
console.log("Error processing SQL: "+err.code);
}
function errorQB(err) {
console.log(' Query error x');
console.log("Error processing SQL: "+err.code);
}
function successCB() {
var db = window.openDatabase("TimeTable", "1.0", "TimeTable" , 1000000);
cosole.log('start of success');
db.transaction(queryDB, errorQB);
console.log('success transaction'); //Didn't Success
}
function onDeviceReady() {
var db = window.openDatabase("TimeTable", "1.0", "TimeTable", 1000000);
db.transaction(populateDB, errorCB, successCB);
}
This is my log:
[INFO] Error processing SQL: 5 //SYNTAX_ERR
Do you know what the problem is ?
Thanks
I knew what I was doing wrong:
I shouldn’t have written the type at the insert statement too … so when I removed it, it worked fine.