Thank you anka001, but not beter..
Did you try the flow I posted above?
Finaly, even a simple 'COUNT' never works
How to integrate that MySQL perfectly working Query into Node-Red???
SELECT COUNT(*) FROM `loinc_be_fr_linguisticvariant` WHERE `SYSTEM`LIKE 'Sang' AND `CLASS` LIKE 'Chimie' AND `SCALE_TYP` LIKE 'Quantitatif' AND `TIME_ASPCT`LIKE 'Temps ponctuel'
I'm not offering any more assistance here.
I just ask a simple solution...
@jbudd asked if you have tried the flow he posted. You have not answered that.
It looks like you are constructing a SQL query dynamically in Node-RED and trying to count the number of records based on certain conditions. The issue you're facing might be related to the way you're constructing the SQL query or processing the result in Node-RED.
Here's a revised version of your Node-RED function:
// Extract values from the incoming payload
var value1 = msg.payload[0].SYSTEM;
var value2 = msg.payload[1].CLASS;
var value3 = msg.payload[2].SCALE_TYP;
var value4 = msg.payload[3].TIME_ASPCT;
// Construct the SQL query
var sqlQuery = 'SELECT COUNT(*) AS nombre FROM loinc_be_fr_linguisticvariant
WHERE ';
sqlQuery += 'SYSTEM
LIKE "' + value1 + '" AND ';
sqlQuery += 'CLASS
LIKE "' + value2 + '" AND ';
sqlQuery += 'SCALE_TYP
LIKE "' + value3 + '" AND ';
sqlQuery += 'TIME_ASPCT
LIKE "' + value4 + '"';
// Set the topic to the SQL query for reference
msg.topic = sqlQuery;
// Return the modified message object
return msg;
Thank you isabelletipa
This return in debug:
17/11/2023 11:39:38node: debug 40
SELECT COUNT(*) AS nombre FROM loinc_be_fr_linguisticvariant WHERE SYSTEM LIKE "Urine" AND CLASS LIKE "Chimie" AND SCALE_TYP LIKE "Quantitatif" AND TIME_ASPCT LIKE "Temps ponctuel" : msg.payload : array[4]
array[4]
0: object
SYSTEM: "Urine"
1: object
CLASS: "Chimie"
2: object
SCALE_TYP: "Quantitatif"
3: object
TIME_ASPCT: "Temps ponctuel"
... but nothing about the COUNT
... and the UI_text is empty...
What happens if you remove the AS nombre
clause?
What happens if you also remove the WHERE clause?
Same...
It can't possibly be the same when you take out the where clause.
With full code:
var value1 = msg.payload[0].SYSTEM;
var value2 = msg.payload[1].CLASS;
var value3 = msg.payload[2].SCALE_TYP;
var value4 = msg.payload[3].TIME_ASPCT;
var sqlQuery = 'SELECT COUNT(*) AS nombre FROM loinc_be_fr_linguisticvariant WHERE ';
sqlQuery += 'SYSTEM LIKE "' + value1 + '" AND ';
sqlQuery += 'CLASS LIKE "' + value2 + '" AND ';
sqlQuery += 'SCALE_TYP LIKE "' + value3 + '" AND ';
sqlQuery += 'TIME_ASPCT LIKE "' + value4 + '"';
msg.topic = sqlQuery;
return msg;
debug return:
SELECT COUNT(*) AS nombre FROM loinc_be_fr_linguisticvariant WHERE SYSTEM LIKE "Urine" AND CLASS LIKE "Chimie" AND SCALE_TYP LIKE "Quantitatif" AND TIME_ASPCT LIKE "Temps ponctuel" : msg.payload : array[4]
array[4]
0: object
SYSTEM: "Urine"
1: object
CLASS: "Chimie"
2: object
SCALE_TYP: "Quantitatif"
3: object
TIME_ASPCT: "Temps ponctuel"
... without 'AS nombre:
var value1 = msg.payload[0].SYSTEM;
var value2 = msg.payload[1].CLASS;
var value3 = msg.payload[2].SCALE_TYP;
var value4 = msg.payload[3].TIME_ASPCT;
var sqlQuery = 'SELECT COUNT(*) FROM loinc_be_fr_linguisticvariant WHERE ';
sqlQuery += 'SYSTEM LIKE "' + value1 + '" AND ';
sqlQuery += 'CLASS LIKE "' + value2 + '" AND ';
sqlQuery += 'SCALE_TYP LIKE "' + value3 + '" AND ';
sqlQuery += 'TIME_ASPCT LIKE "' + value4 + '"';
msg.topic = sqlQuery;
return msg;
debug return:
SELECT COUNT(*) FROM loinc_be_fr_linguisticvariant WHERE SYSTEM LIKE "Urine" AND CLASS LIKE "Chimie" AND SCALE_TYP LIKE "Quantitatif" AND TIME_ASPCT LIKE "Temps ponctuel" : msg.payload : array[4]
array[4]
0: object
SYSTEM: "Urine"
1: object
CLASS: "Chimie"
2: object
SCALE_TYP: "Quantitatif"
3: object
TIME_ASPCT: "Temps ponctuel"
... without WHERE:
var value1 = msg.payload[0].SYSTEM;
var value2 = msg.payload[1].CLASS;
var value3 = msg.payload[2].SCALE_TYP;
var value4 = msg.payload[3].TIME_ASPCT;
var sqlQuery = 'SELECT COUNT(*) FROM loinc_be_fr_linguisticvariant ';
sqlQuery += 'SYSTEM LIKE "' + value1 + '" AND ';
sqlQuery += 'CLASS LIKE "' + value2 + '" AND ';
sqlQuery += 'SCALE_TYP LIKE "' + value3 + '" AND ';
sqlQuery += 'TIME_ASPCT LIKE "' + value4 + '"';
msg.topic = sqlQuery;
return msg;
... debug return:
SELECT COUNT(*) FROM loinc_be_fr_linguisticvariant SYSTEM LIKE "Urine" AND CLASS LIKE "Chimie" AND SCALE_TYP LIKE "Quantitatif" AND TIME_ASPCT LIKE "Temps ponctuel" : msg.payload : array[4]
array[4]
0: object
SYSTEM: "Urine"
1: object
CLASS: "Chimie"
2: object
SCALE_TYP: "Quantitatif"
3: object
TIME_ASPCT: "Temps ponctuel"
???
I found the error
A block was not attached to another...
Many thanks to all
This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.