How to Insert Bool Values to PostgreSQL over Node Red

Hello. I'm a beginner with Node-Red, I try to insert bollean data to PostgreSQL.
For example, I have 4 boolean variables and I need insert this to PostgreSQL table.


My flow is^

I get an error:
"error: invalid syntax for type boolean: """

If I use only payload all is work.

INSERT INTO corp36_pump1(tstamp, on_off, local, disable, alarm)
VALUES (NOW(), '{{msg.payload.on_off}}', true, true, true);

Sorry, this is probably a stupid question. What is correct syntax?

Maybe someone could help me to solve it?

Welcome Comrade!

Each message which arrives at a node is manipulated by the node without any knowledge of previous messages. (There are some exceptions but I don't think the Postgres node is one.)

Each one of the outputs from your "Word to bits" node is a discrete message.
They are each modified by a change node and then they arrive at the "Corp_36 Status" node seperately.

But you are expecting "Corp_36 Status" to handle 4 messages as if they were one.
This is not the way it works. Instead it produces 4 SQL statements something like

INSERT INTO corp36_pump (tstamp, on_off, local, disable, alarm)
VALUES (NOW(), "", true, "", "");

What you can do is:
In your change nodes, set a different msg.topic for each message.
Then use a join node (in Manual mode) to join them into a single message.
Put a debug node after the join so you can see the structure of the newly joined message.

Hello, jbudd!
Thank you very much, your solution is works!
I tested it, all is work. In this wariant will 4 reqest to Postges.

Maybe it will be useful for someone:
changed nodes to convert to single query string (code below)
sql_flows.json (11.4 KB)

jbudd, thanks for your help, I couldn't have done it without you.