In my HTML5, i have a for loop which calls a function to insert into a database. I need this function to be inside a single transaction.
function Ins(id){
db.transaction(function(tx){
tx.executeSql('insert into Product(id) values(?);', [iName], function() {}, function() { });
});
}
The for loop
db.transaction(function(tx){tx.executeSql("BEGIN",[]);});
for (intCountLine=1;intCountLine<=1000;intCountLine++)
{
Ins(intCount);
}
db.transaction(function(tx){tx.executeSql("COMMIT",[]);});
You can see, i have the transaction begin & commit, but i assume when it calls the INS function, it would open a new transaction and close it, everytime it is called. How do i make sure that doesn't happen.
googled it but could not find it... throw me some light here....