How to Check whether the SQL Query was Successful or Failed?


Hi all,

I need to do a checking whether the SQL query was successful or failed in an if else statement for both MySQL (msg.topic) and MSSQL (msg.payload).

For example:

msg.topic = "UPDATE test SET name='Login' WHERE id='123'";

if ( /* Condition to indicate that the query is successful */ ) {
   msg.payload = "Query was successful"; 
else {
   msg.payload = "Query failed";

Tagging @knolleary and @thiren for this topic discussion.


Mmmm. Why do you only want those people to answer?

You set the msg.topic node up in a function node PRIOR to the SQL node where the SQL QUERY is performed so an IF statement where you have it is before the query takes place.

So is that all you have tried? Have you looked at placing a debug AFTER the SQL node? Have you looked at the CATCH or STATUS nodes?