【发布时间】:2015-02-04 16:11:23
【问题描述】:
我在我的 cordova 应用中使用这个插件。
https://github.com/brodysoft/Cordova-SQLitePlugin
我在更新命令期间遇到语法错误问题:
"Error: a statement with no error handler failed: near "(": syntax error (code 1): , while compiling: UPDATE planned_call SET (contact_name, number_to_call, date, note) = ('test','123456', '2014-12-06 16:42','test') WHERE planned_call.id = 5 ;",
我做错了什么? SQL 命令的语法似乎是对的?
感谢您的建议。
该方法的语法如下:
var sqlQuery = "UPDATE planned_call "+
"SET (contact_name, number_to_call, date, note) "+
"= ('"+plannedCall.contact_name+"','"+plannedCall.number_to_call+"', '"+dateTimeOfCall+"','"+plannedCall.note+"') "+
"WHERE planned_call.id = "+plannedCall.id+" ;";
var db = window.sqlitePlugin.openDatabase({name:"callplanner"});
db.transaction(function(tx) {
// init empty array for results
var plannedCalls = [];
tx.executeSql(sqlQuery, [], function(tx,results){
$timeout(function() {
$scope.$apply(function() {
$ionicLoading.show({
template: $translate.instant('UPDATED'),
duration: 500
});
$scope.removeSchelduledAlarmNotification(plannedCall.id);
$scope.addSchelduledAlarmNotification(plannedCall.id, dateTimeOfCall, plannedCall.contact_name, plannedCall.number_to_call, plannedCall.note);
$state.go('planned-calls-today');
});
});
});
}, function(e){
console.log(e);
$ionicLoading.show({
template: $translate.instant('ERROR_DATABASE'),
duration:1000
});
});
【问题讨论】: