Function to create data and insert into column of existing sqlite DB

Thanks both, that were some really useful hints!!!!!
I wasn't aware of the existence of "update" so using this now and its doing what I want, I checked for single values and that is working. I however remain with the problem, that I want to update the entire column of the table with values calculated in the function.

var max_dist = 150; //meter
var stat= 0;
for (var i=0; i<msg.length-4; i++) {
var lat_t= msg.payload[i].Latitude;
var lat_t_1= msg.payload[i][i+1].Latitude;
var dif_lat= Math.abs(lat_t)-Math.abs(lat_t_1)

var lon_t=   msg.payload[i].Longitude;
var lon_t_1= msg.payload[i+1].Longitude;
var dif_lon= Math.abs(lon_t)-Math.abs(lon_t_1)

var dif_tot= Math.sqrt((Math.abs(dif_lat)-Math.abs(dif_lon))**2)*90000

if (dif_tot > max_dist) {stat=1;}
else if (((msg.payload[i+1].UNIX - msg.payload[i].UNIX) > 1000*60*10) ||((msg.payload[i+2].UNIX - msg.payload[i].UNIX) > 1000*60*10)||((msg.payload[i+3].UNIX - msg.payload[i][i].UNIX) > 1000*60*10)||((msg.payload[i+4].UNIX - msg.payload[i].UNIX) > 1000*60*10)){
    stat=0.5;    }
else    {stat=0;}

msg.payload[i].Status=stat;
id_set=msg.payload[i].id; 
}    // here the loop ends and the calculated values are irrelevant since id_set and stat is given manually

id_set=1211;
stat=10;
msg.topic="UPDATE gps SET Status= "+stat+" WHERE id = "+id_set+";"
return msg;

So I don't think its possible to loop over "msg.topic" and "return msg" to update all the entries ( msg.payload[i].Status or stat) at the position "id_set"?
This maybe refers to this post: Update More than one Value with SQLITE - #3 by ilvesheimer
Anyone an idea how to solve this (I don't think I am able to go the batch way)? Originally with the code I wanted to create a string or array that holds all the values which than is of course as long as the table and than add/ update the entire column of the table with it.