Insert data in sqlite without inject node

Hi There !

Can someone help me to review the function node code I've implemented to insert the two variables values hp and lp coming from a Particle Photon?
The idea is not two use inject node but the subscription node from particle contrib which happens every 30 sec.
The function node with red triangle has the following code:

var topic;
var data; // define variables
var hp;
var lp;
var rtmp;
var stmp;
hp=flow.get('hp') || 0; // retrive saved varaibles from the flow
lp=flow.get('lp') || 0;

**X** data= String(hp) +","+ String(lp);  // create string from variables  
msg ="INSERT INTO hvac (UTC, datetimelocal,hp,lp,device) values (datetime('now'),datetime('now','localtime'),data, "Meson2"); "                                                           // from data.

msg.topic= msg;
return msg;

Where is a X the code show the following error message:
I'm cannot realize how to fix that.

This is the partial flow:

Thank you very much in advance.

you have two issues in the function node. First the line starting with **X** data= String... the 'X" is causing an error.
secondly at the end of your INSERT you have double quotes around Meson2 and you should change tehm to single quotes or escape them.

Well, the X was just to show you were the error message was located at the code.
I deleted the "Meson2"

And with this code modified :

var topic;
var data; // define variables
var hp;
var lp;
var rtmp;
var stmp;
hp=flow.get('hp') || 0; // retrive saved varaibles from the flow
lp=flow.get('lp') || 0;

 data= String(hp) +","+ String(lp);  // create string from variables  
msg ="INSERT INTO hvac (UTC, datetimelocal,hp,lp,device) values (datetime('now'),datetime('now','localtime'),data, ); "                                                           // from data.

msg.topic= msg;
return msg;

I got this on the debug tab:

1/25/2020, 9:35:47 PMnode: 58b84b6f.fd0fa4
function : (error)
"Function tried to send a message of type string"

It seems to be that I'm failing to build the message topic to use the INSERT INTO hvac without using an inject node, i mean using function node.

I succeed to insert in db using a inject node like that:

INSERT INTO hvac (UTC, datetimelocal,hp,lp,device) values(datetime('now'),datetime('now', 'localtime'),340,89 ,"Meson2");

But the point is that 340 and 89 values doesn't come from variables.

Thank you for your time.

You are over-writing msg. Just set msg.topic="INSERT... And then return msg;