I need to save the result of an SQLITE SELECT * results so I can email it to another app user so they can import the data to their copy of the app.
I dont know the format I need to save the data as so the other user can import it.
So Far:- Step 1:
db.transacion(function(tx) {
tx.executeSql('SELECT column FROM myTable WHERE my_id=?, [myid], success, error);
Then:
var myData=""
Function success()
var len = results.rows.length;
JavaScript
for (var i=0; i<len; i++) {
myData += '' + results.rows.item(i).mycolum + ', ';
}
End JavaScript
End Function
I then save myData to the device which I then email using a cordova plugin.
Then i need to add the data using sql INSERT
I wont be importing any actual SQL statements just the result of a SELECT statement. I then need to use the result string as variable such as INSERT myVARString into
Thank you for the info, I am already using JSON.stringify() and JSON.parse() but I cant get it to work.
How should I format the SQL results for (transactionresults) ?
I am currently doing this:
//Get the Data
var cerid = "1"
tx.executeSql('SELECT * FROM my_values WHERE my_id=?', [cerid], SysResult, SysError);
});
Function SysResult(tx, results)
JavaScript
var Sysjson=""
var len = results.rows.length;
for (var i=0; i<len; i++){
Sysjson += '('+results.rows.item(i).cert_qu+',\''+results.rows.item(i).cert_ans+ '\',0)';
}
exportMe = (JSON.stringify(Sysjson))
End JavaScript
End function
I then save expotMe to the device so I can email it.
Tip: If you’re pasting code, html or config files, surround the code with triple back ticks (```), before the first line and after the last one. It will be formatted properly.
not sure on the data but you code above should have hyphens around the 0 eg ...s+"', '0', '"+im...
…and all the other other hyphens need to be on the inside of the speech marks
Hi, the current INSERT method is working, but if my_cert_ans contains a JSON string rather than a single value then it fails.
example if my_cert_ans = “Test” ← works
but if my_cert_ans ={“refid”:“1”, “desc”:“VH”, “isfinal”:"", “pd_type”:""} then it fails with format error