Service.js
InsertInToGroup: function(param) {
var deferred = $q.defer();
var promise = deferred.promise;
$cordovaSQLite.execute(db, "INSERT INTO group (title, about_group, category_id, pic, status, del) VALUES (?, ?, ?, ?, ?, ?);", [param.title, param.about_group, parseInt(param.category_id), param.pic, 0, false])
.then(function(res) {
deferred.resolve(res);
}, function(err){
deferred.reject(err);
});
promise.success = function (fn) {
promise.then(fn);
return promise;
}
promise.error = function (fn) {
promise.then(null, fn);
return promise;
}
return promise;
}
I have consumed InsertInToGroup service function to create group. but it's throwing below error
err = Object {message: "sqlite3_prepare_v2 failure: near "group": syntax error", code: 0}
Plugin Installed
ionic plugin add https://github.com/litehelpers/Cordova-sqlite-storage.git#0.7.14
Ionic Version 2.2.2
Please help me to find out the issue
The problem is that group is a keyword. If you really have a table called group the workaround is to put single quotes or double quotes around it.
thanks man, you save my day
Most helpful comment
The problem is that group is a keyword. If you really have a table called group the workaround is to put single quotes or double quotes around it.