Reputation: 96
I'm trying to pass two parameters into sql query from dashDB object in Node-Red flow editor on Bluemix. My parameters are stored in msg.fromDate and msg.toDate and I want to enter them into "Parameter Marker" of dashDB node. When I only use one parameter, I simply type "msg.fromDate" in Parameter Markers and it works fine. In log I see this:
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
Now, when I try to use two input parameters I type "msg.toDate, msg.fromDate" in "Parameter Marker" I'm getting this error in log:
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
How to pass two parameters?
Upvotes: 3
Views: 1049
Reputation: 96
I found the reason for this issue. It looks that when I enter "Parameter Marker" like this:
msg.toDate, msg.fromDate
it does not work. And like this it works:
msg.toDate,msg.fromDate
In other words space between parameters breaks it!
Upvotes: 3
Reputation: 4590
You cannot have quotes between the parameters, not sure if you add quotes just to format your quest or actually added it to your parameters.
I wrote a simple node-red flow with function node
to build the query and the dashDB node
itself.
In my function node
I have the following query:
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;
In the dashDB node
I just have the Parameters Marker text field:
msg.fromDate,msg.toDate
Everything worked fine.
Here is my node-red flow if you want to import it to your own node-red application:
[{"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"]]}]
Upvotes: 1