4
我想創建一個數據庫使用SQLITE與IOS5的電話差距[科爾多瓦1.7.0]。當我增加數據的數量時,查詢失敗&輸出一個錯誤。我跟着存儲API步驟,所以我不知道是什麼問題。我試圖增加數據庫的大小,但它仍然無法工作。Phonegap SQLITE查詢錯誤SYNTAX_ERR
這是我的代碼:
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);
}
這是我的日誌:
[INFO] Error processing SQL: 5 //SYNTAX_ERR
你知道是什麼問題? 感謝