[{"id":"22e38406c0cea71d","type":"tab","label":"Flow 2","disabled":false,"info":"","env":[]},{"id":"b063d1b663175b51","type":"modbus-read","z":"22e38406c0cea71d","name":"LOCATION","topic":"","showStatusActivities":false,"logIOActivities":false,"showErrors":false,"showWarnings":true,"unitid":"","dataType":"HoldingRegister","adr":"1337","quantity":"64","rate":"10","rateUnit":"ms","delayOnStart":false,"startDelayTime":"","server":"50696885b27e228a","useIOFile":false,"ioFile":"","useIOForPayload":false,"emptyMsgOnFail":false,"x":150,"y":60,"wires":[["d24aeacd13d3b3c8"],["6b43d3af2d21efa3"]]},{"id":"d24aeacd13d3b3c8","type":"debug","z":"22e38406c0cea71d","name":"PLC_LOCATION","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload[0]","targetType":"msg","statusVal":"payload[0]","statusType":"auto","x":450,"y":60,"wires":[]},{"id":"6b43d3af2d21efa3","type":"function","z":"22e38406c0cea71d","name":"F_LOCATION","func":"// Create new Buffer based on array bytes\nconst buf = Buffer.from(msg.payload.buffer);\n\n// Convert bytes to string\nconst value = buf.toString('ascii');\n\n// Save the value\nmsg.LOCATION = value;\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":400,"y":120,"wires":[["cc1a4b2051fec5db","5f5477e7a4a80f4f","0445361bae43fad3"]]},{"id":"cc1a4b2051fec5db","type":"debug","z":"22e38406c0cea71d","name":"M_LOCATION","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"LOCATION","targetType":"msg","statusVal":"payload","statusType":"auto","x":680,"y":120,"wires":[]},{"id":"6f10a750c57931cd","type":"MSSQL","z":"22e38406c0cea71d","mssqlCN":"df8c0b88.91b0a8","name":"","outField":"payload","returnType":0,"throwErrors":1,"query":"INSERT INTO dbo.FATIGUE_TEST\r\n (LOCATION, LIVE_LOAD_LBF) \r\nVALUES\r\n (@LOCATION,@LIVE_LOAD_LBF)","modeOpt":"","modeOptType":"query","queryOpt":"payload","queryOptType":"editor","paramsOpt":"","paramsOptType":"editor","rows":"rows","rowsType":"msg","parseMustache":true,"params":[{"output":false,"name":"LOCATION","type":"text","valueType":"msg","value":"LOCATION","options":{"nullable":true,"primary":false,"identity":false,"readOnly":false}},{"output":false,"name":"LIVE_LOAD_LBF","type":"Float","valueType":"msg","value":"LIVE_LOAD_LBF","options":{"nullable":true,"primary":false,"identity":false,"readOnly":false}}],"x":820,"y":260,"wires":[[]]},{"id":"847b3eaf2af8d794","type":"inject","z":"22e38406c0cea71d","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"true","payloadType":"bool","x":150,"y":260,"wires":[["5f5477e7a4a80f4f"]]},{"id":"5f5477e7a4a80f4f","type":"switch","z":"22e38406c0cea71d","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"num"}],"checkall":"true","repair":false,"outputs":1,"x":490.00000381469727,"y":260,"wires":[["6f10a750c57931cd"]]},{"id":"0a1555fe27cf8a85","type":"MSSQL","z":"22e38406c0cea71d","mssqlCN":"df8c0b88.91b0a8","name":"","outField":"payload","returnType":0,"throwErrors":1,"query":"INSERT INTO dbo.FATIGUE_TEST\r\n (LOCATION, LIVE_LOAD_LBF) \r\nVALUES\r\n ('{{{msg.LOCATION}}}','{{{msg.LIVE_LOAD_LBF}}}')","modeOpt":"","modeOptType":"query","queryOpt":"payload","queryOptType":"editor","paramsOpt":"","paramsOptType":"none","rows":"rows","rowsType":"msg","parseMustache":true,"params":[{"output":false,"name":"LOCATION","type":"text","valueType":"global","value":"LOCATION","options":{"nullable":true,"primary":false,"identity":false,"readOnly":false}}],"x":800,"y":340,"wires":[[]]},{"id":"6ba777bbac7f7846","type":"inject","z":"22e38406c0cea71d","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"true","payloadType":"bool","x":130,"y":340,"wires":[["0445361bae43fad3"]]},{"id":"0445361bae43fad3","type":"switch","z":"22e38406c0cea71d","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"num"}],"checkall":"true","repair":false,"outputs":1,"x":470.00000381469727,"y":340,"wires":[["0a1555fe27cf8a85"]]},{"id":"9757b6f4a81b8d39","type":"modbus-read","z":"22e38406c0cea71d","name":"PLC>LOAD_SCALED","topic":"","showStatusActivities":false,"logIOActivities":false,"showErrors":false,"showWarnings":true,"unitid":"","dataType":"HoldingRegister","adr":"304","quantity":"2","rate":"1","rateUnit":"ms","delayOnStart":false,"startDelayTime":"","server":"50696885b27e228a","useIOFile":false,"ioFile":"","useIOForPayload":false,"emptyMsgOnFail":false,"x":840,"y":60,"wires":[["ecac32884385a366","1367854209fcb3e5"],[]]},{"id":"ecac32884385a366","type":"debug","z":"22e38406c0cea71d","name":"PLC_LOAD_SCALED","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":1100,"y":60,"wires":[]},{"id":"1367854209fcb3e5","type":"function","z":"22e38406c0cea71d","name":"F_LIVE_LOAD","func":"let pay = msg.payload;\n\nconst buf = Buffer.allocUnsafe(8);\nbuf.writeUInt16BE(pay[0], 2);\nbuf.writeUInt16BE(pay[1], 0);\n\nmsg.LIVE_LOAD_LBF = buf.readFloatBE(0);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1040,"y":120,"wires":[["cf25442157169d43","5f5477e7a4a80f4f","0445361bae43fad3"]]},{"id":"cf25442157169d43","type":"debug","z":"22e38406c0cea71d","name":"M_LIVE_LOAD","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"LIVE_LOAD_LBF","targetType":"msg","statusVal":"payload","statusType":"auto","x":1220,"y":120,"wires":[]},{"id":"50696885b27e228a","type":"modbus-client","name":"PLC","clienttype":"tcp","bufferCommands":true,"stateLogEnabled":false,"queueLogEnabled":false,"failureLogEnabled":false,"tcpHost":"192.168.0.10","tcpPort":"502","tcpType":"DEFAULT","serialPort":"/dev/ttyUSB","serialType":"RTU-BUFFERD","serialBaudrate":"9600","serialDatabits":"8","serialStopbits":"1","serialParity":"none","serialConnectionDelay":"100","serialAsciiResponseStartDelimiter":"0x3A","unit_id":"1","commandDelay":"0","clientTimeout":"1000","reconnectOnTimeout":true,"reconnectTimeout":"2000","parallelUnitIdsAllowed":true},{"id":"df8c0b88.91b0a8","type":"MSSQL-CN","tdsVersion":"7_4","name":"JOI_MSSQL","server":"localhost","port":"1433","encyption":true,"trustServerCertificate":true,"database":"Fatigue_Test","useUTC":true,"connectTimeout":"","requestTimeout":"","cancelTimeout":"","pool":"","parseJSON":false,"enableArithAbort":true}]
New to Node-Red and SQL.
I am reading values from a PLC via MODBUS and attempting to insert into MSSQL on localhost. The MODBUS values are coming in correctly, and I am successfully connected to MSSQL.
As a test, I'm attempting to insert a text and a float into MSSQL. The first way using the paramaters in the MSSQL-PLUS node only inserts NULL. The second way using only the query inserts nothing for the text and 0 for the real (expecting the real to be -0.8xx).