我试图将两个参数从Bluemix上的Node-Red流编辑器中的dashDB对象传递到sql查询中。我的参数存储在msg.fromDate和msg.toDate中,我想将它们输入到"参数标记" dashDB节点。当我只使用一个参数时,我只需在参数标记中键入" msg.fromDate" ,它就可以正常工作。在日志中我看到了:
2015-12-10T12:22:12.856 + 0100 [App / 0] out输入节点:pathToArray: msg,toDate 2015-12-10T12:22:12.856 + 0100 [App / 0] out输入节点:parameterValues: 2015-12-01
现在,当我尝试使用两个输入参数时,我在"参数标记"中输入" msg.toDate,msg.fromDate" 。我在日志中收到此错误:
2015-12-10T12:26:01.271 + 0100 [App / 0] out 12 Dec 11:26:01 - [错误] [dashDB in:热门词汇] TypeError:无法读取属性' fromDate' 未定义的
2015-12-10T12:26:01.270 + 0100 [App / 0] out输入节点:pathToArray: msg,toDate,msg,fromDate
如何传递两个参数?
答案 0 :(得分:3)
我找到了这个问题的原因。当我输入“参数标记”时,它看起来像这样:
msg.toDate, msg.fromDate
它不起作用。它是这样的:
msg.toDate,msg.fromDate
换句话说,参数之间的空格会破坏它!
答案 1 :(得分:1)
参数之间不能有引号,不确定是否只是添加引号来格式化你的任务或者实际将它添加到你的参数中。
我用function node
编写了一个简单的节点红色流程来构建查询和dashDB node
本身。
在我的function node
中,我有以下问题:
msg.fromDate = '2011-04-12 00:00:00';
msg.toDate= '2015-03-12 00:00:00';
msg.payload = "SELECT COL2 FROM DASH104951.TESTDATE WHERE START >= ? AND END <= ?";
return msg;
在dashDB node
我只有参数标记文本字段:
msg.fromDate,msg.toDate
一切都很好。
如果要将其导入到您自己的节点红色应用程序中,这是我的节点红色流程:
[{"id":"211a834b.dee57c","type":"inject","z":"197f318.fe680ce","name":"","topic":"","payload":"","payloadType":"none","repeat":"","crontab":"","once":false,"x":117,"y":115,"wires":[["7a23c994.85dc38"]]},{"id":"7a23c994.85dc38","type":"function","z":"197f318.fe680ce","name":"Build Query","func":"msg.fromDate = '2011-04-12 00:00:00';\nmsg.toDate= '2015-03-12 00:00:00';\nmsg.payload = \"SELECT COL2 FROM DASH104951.TESTDATE WHERE START >= ? AND END <= ?\";\nreturn msg;","outputs":1,"noerr":0,"x":325,"y":123,"wires":[["559c92e4.aa636c"]]},{"id":"24974090.db68c","type":"debug","z":"197f318.fe680ce","name":"dashDB query result","active":true,"console":"false","complete":"true","x":773,"y":125,"wires":[]},{"id":"559c92e4.aa636c","type":"dashDB in","z":"197f318.fe680ce","service":"dashDB-0a","query":"","params":"msg.fromDate,msg.toDate","name":"","x":548,"y":131,"wires":[["24974090.db68c"]]}]