我正在使用nodered创建一个环聊机器人。我在Azure上有一个SQL数据库,对于每个用户,我在msg.conversationId
中保存了一个ID,我想将此ID传递给查询。
我用这个查询创建了一个函数“sql query”:
msg.payload = {action: "Q", query: `SELECT a = ISNULL(Nome, null) FROM Users WHERE id_conversation=${msg.conversationId};`};
但是,我当然错了
这是节点红色流程:
有没有人有任何建议?非常感谢!
答案 0 :(得分:0)
调试脚本插入
node.error(msg.payload);
在msg.payload定义之后,在调试选项卡中输出数据。
尝试连接字符串
msg.payload = {action: "Q", query: "SELECT a = ISNULL(Nome, null) FROM Users WHERE id_conversation=" + msg.conversationId + ";"};
替代:
var query = "SELECT a = ISNULL(Nome, null) FROM Users WHERE id_conversation=" + msg.conversationId + ";";
msg.payload = {action: "Q", query: query};