0

I have problem with asynchronous call of INSERT in db.transaction when parsing large CSV.

Problem #1:

while(...parse CSV...) {
db.transaction{
...tx.executeSql(INSERT...
}
}

...it will enter the last row X times (X ... number of rows in CSV)

Problem #2:

db.transaction{
while(...parse CSV...) {
...tx.executeSql(INSERT...
}
} 

...it will reach some limit and will not insert anything (if I don't use while, but for like <10, it works, but this limit is quite small).

It is similar to this question: Web SQL Database + Javascript loop, but the recursion will not help here.

Thanks!

Community
  • 1
  • 1
  • Example #1 won't work because you're creating multiple transactions asynchronously within a while loop, which is bad. Example #2 is better, because you're doing 1 transaction instead of many, and looping within the single transaction. However, please add actual code for example #2 so we can try and see why a limit is being imposed :) – Chris McFarland Nov 02 '11 at 17:27

1 Answers1

0

I've found a sollution. It is better to divide these two things - parse CSV and then call some function like saveOneRow(column1, column2...) with transaction in this function.