如何将两个参数传递给 IBM Bluemix 的 Node-Red 的 dashDB 查询元素
How to pass two parameters to dashDB query element of Node-Red from IBM Bluemix
我正在尝试将两个参数从 Bluemix 上的 Node-Red 流编辑器中的 dashDB 对象传递到 sql 查询。我的参数存储在 msg.fromDate 和 msg.toDate 中,我想将它们输入到 dashDB 节点的 "Parameter Marker" 中。当我只使用一个参数时,我只需在参数标记中键入 "msg.fromDate" 即可正常工作。在日志中我看到了这个:
2015-12-10T12:22:12.856+0100 [App/0] out Input node: pathToArray:
msg,toDate 2015-12-10T12:22:12.856+0100 [App/0] out Input node: parameterValues: 2015-12-01
现在,当我尝试使用两个输入参数时,我在 "Parameter Marker" 中键入 "msg.toDate, msg.fromDate" 我在日志中收到此错误:
2015-12-10T12:26:01.271+0100 [App/0] out 10 Dec 11:26:01 - [error]
[dashDB in:popular words] TypeError: Cannot read property 'fromDate'
of undefined
2015-12-10T12:26:01.270+0100 [App/0] out Input node: pathToArray:
msg,toDate, msg,fromDate
如何传递两个参数?
参数之间不能有引号,不确定添加引号只是为了格式化任务还是实际将其添加到参数中。
我用 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
一切正常。
如果你想将它导入到你自己的 node-red 应用程序中,这是我的 node-red 流程:
[{"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"]]}]
我找到了这个问题的原因。看起来当我这样输入 "Parameter Marker" 时:
msg.toDate, msg.fromDate
它不起作用。就像这样它起作用了:
msg.toDate,msg.fromDate
换句话说参数之间的space打破了它!
我正在尝试将两个参数从 Bluemix 上的 Node-Red 流编辑器中的 dashDB 对象传递到 sql 查询。我的参数存储在 msg.fromDate 和 msg.toDate 中,我想将它们输入到 dashDB 节点的 "Parameter Marker" 中。当我只使用一个参数时,我只需在参数标记中键入 "msg.fromDate" 即可正常工作。在日志中我看到了这个:
2015-12-10T12:22:12.856+0100 [App/0] out Input node: pathToArray: msg,toDate 2015-12-10T12:22:12.856+0100 [App/0] out Input node: parameterValues: 2015-12-01
现在,当我尝试使用两个输入参数时,我在 "Parameter Marker" 中键入 "msg.toDate, msg.fromDate" 我在日志中收到此错误:
2015-12-10T12:26:01.271+0100 [App/0] out 10 Dec 11:26:01 - [error] [dashDB in:popular words] TypeError: Cannot read property 'fromDate' of undefined
2015-12-10T12:26:01.270+0100 [App/0] out Input node: pathToArray: msg,toDate, msg,fromDate
如何传递两个参数?
参数之间不能有引号,不确定添加引号只是为了格式化任务还是实际将其添加到参数中。
我用 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
一切正常。
如果你想将它导入到你自己的 node-red 应用程序中,这是我的 node-red 流程:
[{"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"]]}]
我找到了这个问题的原因。看起来当我这样输入 "Parameter Marker" 时:
msg.toDate, msg.fromDate
它不起作用。就像这样它起作用了:
msg.toDate,msg.fromDate
换句话说参数之间的space打破了它!