Is it possible to use only a single database node like (mssql) to run sequential queries in node-red?

Hi Everyone,

I need to an insert query to store a record on MS SQL Server. Once the insert query is successful, i need to run a select query to another table, based on the id (Primary key) of the newly inserted record from the first query.

It seems that i need use two mssql nodes for this purpose. And if i have to execute more queries sequentially, then i need to keep on adding new more mssql nodes.

Is there any way to only use a single mssql node and run different types of queries one after another? I would be really glad if anyone could help me to clear my confusions or misunderstandings.

Thanks in advance.

Best Regards,

Firstly, that node is pretty much abandond (and has known issues) - you should remove it an use the node-red-contrib-mssql-plus node.

So in the query, you can do things like this...


All that said - what is the harm in multiple nodes?

  • They use a config so there is a shared (pooled) connection
  • They give you a graphical means of understanding the flow (i.e. low code)

I suspect the functions you wrote could also be replaced with the low code nodes like switch and change

1 Like

Hello Steve,

First of all, thank you very much for the detailed explanation and also for guiding me to use node-red-contrib-mssql-plus in an efficient way. This is very helpful.

And yes there is infact no any harm in using multiple nodes. If it could be controlled, i just wanted to avoid occupying more flow area while defining nodes with same configuration.

But i have a better understanding now. Thank you very much.

Best Regards,
Nirajan

Well, the config is set once & shared across all MSSQL-PLUS nodes.

However, if you mean you have same query and input parameters and want to re-use it, then the link call --> link in --> MSSQL --> link out (return mode) node is perfect for that...

Hello Steve,

I will have a look at it as well. Thank you very much for the information.

Best regards,
Nirajan

Sorry, didn't maybe read your question very well but couldn't you simply do a combined SQL command with 2 statements. 1 to do the update and the 2nd to do the query? Does the SQL+ node allow that?

:point_down:urm :point_down: ...

:smiley:

Ah, there you go then! Told you I probably hadn't read it properly! (Goofing around over lunch on a Friday afternoon - never really a good idea!).

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.