Logging data in to MSSQL

You have several mistakes in your flow.

  1. As @zenofmud points out, you have undeclared variables in your flow
    • NB: The function is utterly pointless here
  2. You have the MSSQL-PLUS node set to use the SQL in the UI - BUT - you are attempting to pass a SQL STRING in via msg.topic
    • NB: This is the least safe way of doing SQL - you should use parameters in the UI to avoid SQL injection

image

Demo flow...

[{"id":"ee57a1d4778d19aa","type":"MSSQL","z":"49f61d916c8f6022","mssqlCN":"358e71158db79bf8","name":"read","outField":"payload","returnType":0,"throwErrors":1,"query":"INSERT INTO pco2 \r\n    (door_status,temp,upper_limit,lower_limit) \r\nVALUES\r\n    (@doorstatus, @temp, @upper_limit, @lower_limit)\r\n","modeOpt":"queryMode","modeOptType":"query","queryOpt":"payload","queryOptType":"editor","paramsOpt":"","paramsOptType":"editor","rows":"rows","rowsType":"msg","params":[{"output":false,"name":"door_status","type":"VarChar","valueType":"global","value":"dipco2lwr","options":{"nullable":true,"primary":false,"identity":false,"readOnly":false}},{"output":false,"name":"temp","type":"Float","valueType":"global","value":"rtdpco2","options":{"nullable":true,"primary":false,"identity":false,"readOnly":false}},{"output":false,"name":"upper_limit","type":"Float","valueType":"global","value":"pco2-low","options":{"nullable":true,"primary":false,"identity":false,"readOnly":false}},{"output":false,"name":"lower_limit","type":"Float","valueType":"global","value":"pco2-up","options":{"nullable":true,"primary":false,"identity":false,"readOnly":false}}],"x":1490,"y":100,"wires":[[]]},{"id":"358e71158db79bf8","type":"MSSQL-CN","tdsVersion":"7_4","name":"","server":"localhost","port":"1433","encyption":false,"trustServerCertificate":false,"database":"DATA","useUTC":false,"connectTimeout":"15000","requestTimeout":"15000","cancelTimeout":"5000","pool":"5","parseJSON":false,"enableArithAbort":true}]
1 Like