Results 1 to 5 of 5
  1. adma84's Avatar
    Posts
    285 Posts
    Global Posts
    323 Global Posts
       #1  
    Has anyone tried the method noted here: Mojo Storage Database - WebOS Internals

    for inserting multiple rows at once? It just hangs on me when it gets to the execute statement. Thanks for any help!
    My Programs: TipIt(TipCalc), FillUps
  2. #2  
    Quote Originally Posted by adma84 View Post
    Has anyone tried the method noted here: Mojo Storage Database - WebOS Internals

    for inserting multiple rows at once? It just hangs on me when it gets to the execute statement. Thanks for any help!
    I've done something similar in my code; however, the "var sql = " statement doesn't need to be in the for loop.

    You might have a typo or something causing an exception in your execute statement. Maybe you can post your code and we can check it out.
  3. adma84's Avatar
    Posts
    285 Posts
    Global Posts
    323 Global Posts
       #3  
    thanks man, here is some code:

    Code:
    ImportDataAssistant.prototype.transferDataIntoTable = function(results){
    	
    	Mojo.Log.info("Entered transferDataIntoTable method")
    	Mojo.Log.info("We have %d records to import.", this.fillupList.length)
    	var stationLocation = "" //I don't import this yet
    	var tableName = this.vkey
    	var length = this.fillupList.length
    	Mojo.Log.info("Does this work", this.fillupList[0].date)
    	
    		gasDB.transaction(function(transaction){ 
    		
    			for (var i=0; i < length; i++) {
    				
    				var string = "INSERT INTO " + tableName + " VALUES(?,?,?,?,?,?,?,?);"
    				Mojo.Log.info("<------------:SQL STRING:", string);
    				var temp = this.fillupList[i]
    				
    				transaction.executeSql(string, [temp.date, temp.odometer, temp.fillupType, temp.gallons, temp.costGallon, temp.total, temp.gasStation, stationLocation], 
    				function(transaction, results){
    					Mojo.Log.info("successfully inserted record")
    				}.bind(this), this.errorHandler.bind(this));
    			}
    		});
    	
    	Mojo.Log.info("Exited transferDataIntoTable method")
    }
    I know the code looks terrible, but I have screwed with it so much to make it work. I don't even get calls to my errorhandler. I use SQL all over the rest of my program, but since this is the import class, and I am importing 50+ rows at a time, so I thought the for loop would work best.
    My Programs: TipIt(TipCalc), FillUps
  4. adma84's Avatar
    Posts
    285 Posts
    Global Posts
    323 Global Posts
       #4  
    I don't know what I was doing wrong, but I just deleted it and started over. All is well now! Thanks so much!
    My Programs: TipIt(TipCalc), FillUps
  5. #5  
    this doesn't work if you have too many rows. I don't have a firm definition of too many
    but it's less than 500

    RIck

Posting Permissions