Results 1 to 5 of 5
  1.    #1  
    Got a problem with the asynchronous nature of inserting records.

    I have a loop whereby I am inserting 18 records 1 after the other. The problem is that since the SQL statement is being executed asynchronously all 18 records have the values of the 18th record

    There must be a way to handle this. Is it possible to turn off asynchronous for inserts?
  2.    #2  
    Here's the code I am executing. Just looping through a number of items in an array and performing an insert for each row of the array.
    for (var i = 0; i < 17; i++) {
    			transaction.executeSql("INSERT INTO course_holes (course_id, tee_id, holenum, distance, par, handicap, frontlat, frontlong, midlat, midlong, backlat, backlong)" +
    			"VALUES (?,?,?,?,?,?,?,?,?,?,?,?);", 
    			[results.rows.item(0).id, 1, this.tempHoles.items[i].number, null, this.tempHoles.items[i].par, this.tempHoles.items[i].handicap,
    	 		this.tempHoles.items[i].flat, this.tempHoles.items[i].flong,
    	 		this.tempHoles.items[i].clat, this.tempHoles.items[i].clong,
    	 		this.tempHoles.items[i].blat, this.tempHoles.items[i].blong]);
  3. #3  
    You can also run the loop inside the transaction. The only difference is that if one insert fails (when the loop is inside the transaction) all the others are canceled and rolled back.
  4.    #4  

    Thanks for the info, but not sure I fully follow what you mean by running the loop inside the transaction. Could you elaborate ?
  5.    #5  
    Ok, got it now Seems to be working fine.

    Ta muchly

Posting Permissions