Hi I am trying to import some pieces of a long text into SQLite table but I have the following problem.
I use the bellow code in order to read the long text stored in a test DB.
var mycollectoridlength = 0, mybill, line = 0;
notesdb.transaction(function(t) {
t.executeSql('SELECT * FROM billtest;', [], function(t, bulkdata){
mybill = bulkdata.rows.item(0);
and then loop through long text and try to insert some pieces of it into another DB.
for (i = 1; i <= ((mybill.testtext.length)/126); i += 1) {
alert(line) // alerts 1, 126, 252 ...
t.executeSql('INSERT OR IGNORE into buildings (buildingcode, buildingaddress, buildingcollect, buildingpay) VALUES (?,?,?,?);',
[mybill.testtext.substr((line+0), 5).trim(), mybill.testtext.substr((line+44), 40).trim(), 0, 0], function(){
alert(line) // alerts 10962 (87 * 126)
});
line = i * 126;
}
but the line inside executeSql is not sync with the loop. The SQLite insertion executed after the loop. How can I solve it???
Aucun commentaire:
Enregistrer un commentaire