First of all I'm a newbie using node-red. I'm trying to insert some data into oracle database using oracledb-mod. As you can see on prints I'm facing some errors to just to insert. I had success to select data.
I'm broke the code into small step to understand node-red structure, but I dont have success yet.
Following the docs, msg.payload is an array in oracledb-mod, but it doesn't work for me.
I'm glade if someone could help me.
The help states
msg.payload: array containing the fields to be used inside the query, first element in the array corresponds with the first
:fieldname parameter in the query etc.
Which suggests you change the
msg.payload[x] in the
:fieldname but that makes little sense.
:0, :1, :2 or perhaps
:1, :2, :3?
Failing try a different oracle node?
Thank you sugget, I try somthing litle diferent. I used a function node to return msg.query as documentation .
Now I can insert data by query string.
Thanks a lot.
Just be careful. Dynamic queries are susceptible to SQL Injection. You would be far better of trying to use parameters.
Did you try using what i suggested:
Looking at that screenshot suggests there is another place you may need to setup - did you enter anything in the "Field Mappings"?
At a guess (I have never used this node - as I do not use oracle), you tell the Field Mappings where the data is in your payload then use the field mappings like this...
INSERT INTO automacao.variaveis
(codigo, datger, valor)
VALUES (:codigo, :datger, :valor)
Thank you about your concern and clue by SQL Injection.
I dont know how "Field Mappings" works, but I try doing what you said. I'm not sure if it make sense.
My function returns an array.
I'm trying diferents ways to solve this problem, if you find any error on it let me know.