# Function node, edit message is not working in database

**URL:** <https://discourse.nodered.org/t/function-node-edit-message-is-not-working-in-database/56846>\
**Category:** General\
**Created:** [18 January 2022 10:34 UTC](https://discourse.nodered.org/t/function-node-edit-message-is-not-working-in-database/56846 "2022-01-18T10:34:42Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![josemspedro](https://avatars.discourse-cdn.com/v4/letter/j/8e7dd6/32.png) [@josemspedro](https://discourse.nodered.org/u/josemspedro)\
**Post date:** [18 January 2022 10:34 UTC](https://discourse.nodered.org/t/function-node-edit-message-is-not-working-in-database/56846/1 "2022-01-18T10:34:42Z")

</div>

Hello,  
I am using the nodes in the picture below to write an integer in a label(dashboard) and write it in a database.

 ![nodes](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/7/f7b1c8196c07a2323234c518dd681ade89a81b63.png)  
You can see the code of the function node in the picture to Update the database with the variable.  
 ![code](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/8/287d0e140412230d66c2b6e88d1c86618474b022.png)  
However, in debug appears "Error: Unknown column 'power' in 'field list'  
Can someone help me??

---

<div class="post-metadata">

**Author:** ![kuema](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/kuema/32/6542_2.png) [@kuema](https://discourse.nodered.org/u/kuema)\
**Post date:** [18 January 2022 10:43 UTC](https://discourse.nodered.org/t/function-node-edit-message-is-not-working-in-database/56846/2 "2022-01-18T10:43:15Z")

</div>

The way you pass your parameter isn't correct. Basically you're telling MySQL to set the value of `potencia` to the value of another column named `power`, which doesn't exist.

Try using a placeholder `?` in your query and pass the parameter as payload in an array.  
That also has the benefit of preventing SQL injections, since the mysql lib will take care of any escaping.

```auto
msg.topic = "... set potencia=? where ..." // omitted the rest
msg.payload = [power];

```

---

<div class="post-metadata">

**Author:** ![josemspedro](https://avatars.discourse-cdn.com/v4/letter/j/8e7dd6/32.png) [@josemspedro](https://discourse.nodered.org/u/josemspedro)\
**Post date:** [18 January 2022 11:14 UTC](https://discourse.nodered.org/t/function-node-edit-message-is-not-working-in-database/56846/3 "2022-01-18T11:14:30Z")

</div>

Yeah. It works. Thank you....

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [1 February 2022 11:15 UTC](https://discourse.nodered.org/t/function-node-edit-message-is-not-working-in-database/56846/4 "2022-02-01T11:15:13Z")

</div>

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