smchamberlin / node-red-contrib-ibm-db2

Node-RED nodes to work with a Db2 LUW database. Works with "Db2 on Cloud" and "Db2 Warehouse on Cloud" services as well as standalone installation of Db2 LUW.
4 stars 14 forks source link

When msg.payload contains SQL statement, node retains first statement #3

Closed WilliamBradee closed 8 years ago

WilliamBradee commented 8 years ago

I tried to create a single node to run various SQL queries. Node allows passing in SQL as msg.payload. This works, however it latches the first msg.payload and thereafter only runs this query. If this worked I could set up a local REST service to execute SQL (OK would need to protect) to avoid previous 1 connection per node issue.

Expected behavior - honor each new msg.payload SQL statement.

Example Nodes (including DDL to set up table in comment). It runs 2 queries to insert into 2 different tables. screenshot

[{"id":"7d865081.8279b","type":"sqldb in","z":"e5fe3fae.1a01c","service":"SQL Database-v5","query":"","params":"","name":"","x":592.8957366943359,"y":242.88888549804688,"wires":[["2b6e1029.d491f"]]},{"id":"d2dab8d5.2d2548","type":"function","z":"e5fe3fae.1a01c","name":"INSERT TABLE 1","func":"msg.payload = \"INSERT INTO TABLE1 (COL1,COL2) VALUES(1,'T1')\";\nreturn msg;","outputs":1,"noerr":0,"x":352.8958282470703,"y":190.88888549804688,"wires":[["7d865081.8279b"]]},{"id":"5834ccc6.a7cb34","type":"function","z":"e5fe3fae.1a01c","name":"INSERT TABLE 2","func":"msg.payload = \"INSERT INTO TABLE2 (COL1,COL2) VALUES(2,'T2')\";\n\nreturn msg;","outputs":1,"noerr":0,"x":362.8958282470703,"y":296.8888854980469,"wires":[["7d865081.8279b"]]},{"id":"585ac579.a7a53c","type":"inject","z":"e5fe3fae.1a01c","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":161.8958282470703,"y":189.88888549804688,"wires":[["d2dab8d5.2d2548"]]},{"id":"aaf08224.550f8","type":"inject","z":"e5fe3fae.1a01c","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":164.8958282470703,"y":295.8888854980469,"wires":[["5834ccc6.a7cb34"]]},{"id":"2b6e1029.d491f","type":"debug","z":"e5fe3fae.1a01c","name":"","active":true,"console":"false","complete":"false","x":783.8957977294922,"y":242.88888549804688,"wires":[]},{"id":"ec4bfa3b.13b408","type":"comment","z":"e5fe3fae.1a01c","name":"setup","info":"Sql database added in bluemix\n\nTable 1:\n\nCREATE TABLE table1 \n(\n COL1 INT,\n COL2 VARCHAR(5) \n);\n\nTable 2:\n\nCREATE TABLE table1 \n(\n COL1 INT,\n COL2 VARCHAR(5) \n);","x":142.8958282470703,"y":124.88888549804688,"wires":[]}]

smchamberlin commented 8 years ago

Should be fixed now - I tested with your flow - please verify on your side. Thanks for reporting this!