Add support for batch of SQL statements (#466)

* Add support for batch of SQL statements
This commit is contained in:
tmdoit
2018-07-19 13:33:43 +02:00
committed by Dave Conway-Jones
parent 911f739005
commit e308b0c1f9
2 changed files with 21 additions and 6 deletions

View File

@@ -55,10 +55,23 @@ module.exports = function(RED) {
});
}
else {
if (typeof msg.topic !== 'string') {
node.error("msg.topic : the query is not defined as a string",msg);
node.status({fill:"red",shape:"dot",text:"msg.topic error"});
}
node.error("msg.topic : the query is not defined as a string",msg);
node.status({fill:"red",shape:"dot",text:"msg.topic error"});
}
}
if (this.sqlquery == "batch") {
if (typeof msg.topic === 'string') {
node.mydbConfig.db.exec(msg.topic, function(err) {
if (err) { node.error(err,msg);}
else {
msg.payload = [];
node.send(msg);
}
});
}
else {
node.error("msg.topic : the query is not defined as string", msg);
node.status({fill:"red", shape:"dot",text:"msg.topic error"});
}
}
if (this.sqlquery == "fixed"){