我目前正在开发一些以前由一些前开发者为一家小公司设置的应用程序。在发出PUT请求更新用户的帐户信息后检查响应对象时,我收到此错误:
SQLSTATE = 42601 SQLCODE = -104令牌,无效。
我假设这意味着它有一个“,”它不属于某个地方,但我似乎无法找到它。
以下是查询:
update
@lib3.usermst
set
usfirstn = upper('@firstnm'),
usmidint = upper('@mi'),
uslastn = upper('@lastnm'),
usbusnam = upper('@busnm'),
usaddr1 = upper('@addr1'),
usaddr2 = upper('@addr2'),
usaddr3 = upper('@addr3'),
uscity = upper('@city'),
usstate = upper('@state'),
uszip = @zip,
uszipext = @zipExt,
usphone1 = @phone1,
usphntyp1 = substr('@phoneType1', 1, 1),
usphone2 = @phone2,
usphntyp2 = substr('@phoneType2', 1, 1),
usphone3 = @phone3,
usphntyp3 = substr('@phoneType3', 1, 1),
usemail = upper('@email'),
usqrecid1 = @qrecid1,
usanswer1 = upper('@ans1'),
usqrecid2 = @qrecid2,
usanswer2 = upper('@ans2'),
usqrecid3 = @qrecid3,
usanswer3 = upper('@ans3'),
uschgdat = Current Date,
uschgtim = Current Time,
uschgusr = upper('@userId')
where
usrecid = @clientId
我是在正确的轨道上,还是我完全离开了?
在SQL对象中的Node中看起来像什么
var SQL = {
client_UpdateProfile: "update @lib3.usermst set usfirstn = upper('@firstnm'), " +
"usmidint = upper('@mi'), uslastn = upper('@lastnm'), usbusnam = upper('@busnm'), " +
"usaddr1 = upper('@addr1'), usaddr2 = upper('@addr2'), usaddr3 = upper('@addr3'), " +
"uscity = upper('@city'), usstate = upper('@state'), uszip = @zip, uszipext = @zipExt, " +
"usphone1 = @phone1, usphntyp1 = substr('@phoneType1', 1, 1), usphone2 = @phone2, usphntyp2 = substr('@phoneType2', 1, 1), " +
"usphone3 = @phone3, usphntyp3 = substr('@phoneType3', 1, 1), usemail = upper('@email'), " +
"usqrecid1 = @qrecid1, usanswer1 = upper('@ans1'), " +
"usqrecid2 = @qrecid2, usanswer2 = upper('@ans2'), usqrecid3 = @qrecid3, " +
"usanswer3 = upper('@ans3'), uschgdat = Current Date, uschgtim = Current Time, " +
"uschgusr = upper('@userId') " +
"where usrecid = @clientId",
...
}
以下是查询的执行方式
module.exports.updateProfile = function (clientId, userId, req, callback) {
var err = {};
var data = {};
var query = SQL.client_UpdateProfile;
query = query.replace("@lib3", config.library3);
query = query.replace("@clientId", clientId);
query = query.replace("@firstnm", req.body.firstnm);
query = query.replace("@mi", req.body.mi);
query = query.replace("@lastnm", req.body.lastnm);
query = query.replace("@busnm", req.body.busnm);
query = query.replace("@addr1", req.body.addr1);
query = query.replace("@addr2", req.body.addr2);
query = query.replace("@addr3", req.body.addr3);
query = query.replace("@city", req.body.city);
query = query.replace("@state", req.body.state);
query = query.replace("@zip", req.body.zip);
query = query.replace("@zipExt", req.body.zipExt);
query = query.replace("@phone1", req.body.phone1);
query = query.replace("@phoneType1", req.body.phoneType1);
query = query.replace("@phone2", req.body.phone2);
query = query.replace("@phoneType2", req.body.phoneType2);
query = query.replace("@phone3", req.body.phone3);
query = query.replace("@phoneType3", req.body.phoneType3);
query = query.replace("@email", req.body.email);
query = query.replace("@qrecid1", req.body.qrecid1);
query = query.replace("@qrecid2", req.body.qrecid2);
query = query.replace("@qrecid3", req.body.qrecid3);
query = query.replace("@ans1", req.body.ans1);
query = query.replace("@ans2", req.body.ans2);
query = query.replace("@ans3", req.body.ans3);
query = query.replace("@userId", userId);
DB.runQuery(query, function (err, data) {
if (err) {
err = ERROR.client_ProfileNotUpdated;
} else {
err = ERROR.client_ProfileUpdated;
}
callback(err, data);
});
};