我创建了更新查询:我收到以下错误:错误:“ =” 或附近的语法错误。我发布了整个API。 1个API中有2个查询,table_name值从一个查询传递到另一个 我不明白我的错误。
table_name = abc
status_id = 111
spf_id = 1
PUT方法API:
router.put('/update', function(req, httpres, next) {
console.log("Inside");
const role_id = Role_id.Role
console.log("Inside the update api",role_id);
console.log("stage 1")
pool.query("SELECT table_name FROM roles WHERE role_id="+role_id+"")
.subscribe(
data => {
console.log('success 1st query',data)
table_name = data.rows[0].table_name;
console.log("table_name: ",table_name)
})
const spf_id = req.body.spf_id;
const status_id = req.body.status.status;
console.log("Inside the update 2 api",spf_id,status_id,table_name);
pool.query("UPDATE "+table_name+" SET status_id ="+status_id+" WHERE spf_id ="+spf_id+" ")
.subscribe(
data => {
console.log('success 2nd query',data)
}, err => {
console.log('error',err)
// httpres.send('error');
})
});