Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Web and WebWorks Development

Reply
Contributor
Posts: 18
Registered: ‎12-20-2010
My Device: bold
My Carrier: webmaster

sqlite html5 callback afer select statment

Hi Everyboy,

 

As the new support of html5 in os6 I have to recode my sqlite cause I'ts now synchronous...

 

So my code :

 

function array_fill(Ind){
    db.transaction(function(tx){
                
    tx.executeSql("SELECT TB"+Ind+" FROM TABLE;", null, insere);    
                    
    function insere(tx, rs){
        
    var rows = rs.rows;
    if (rows && rows.length) {
        for(var i = 0; i < rows.length; i++) {
            var row = rows.item(i);
            tgh[i]=eval("row.TB"+Ind);                            
        }

    }    

    return tgh;
    }
                    
    });        
}

 

the problem is my array (tgh) is not returned.

How can I implement a callback ?

 

Thanks a lot for your help.

Michel

Highlighted
Developer
Posts: 482
Registered: ‎10-24-2008
My Device: 9300
My Carrier: AT&T

Re: sqlite html5 callback afer select statment

Hello don_miguel, 

 

it looks like you have some formatting issues with brackets... here is an example of a sqlite callback from one of my applications.

 

 

_db.transaction(function(tx){
   tx.executeSql('DELETE FROM Notes WHERE ROWID=?', [theCurrentNoteID],
      function(){
         var d = document.getElementById(theCurrentNoteID);
         d.parentNode.removeChild(d);
         window.sessionStorage.removeItem(theCurrentNoteID);
      },function(){});
});

 So, just guessing your intent and looking at the code... does it make sense to be rewritten like below?

 

 

function array_fill(Ind){
    db.transaction(function(tx){           
       tx.executeSql("SELECT TB"+Ind+" FROM TABLE;", null, insere);    
    });        
}

function insere(tx, rs){    
    var rows = rs.rows;
    if (rows && rows.length) {
        for(var i = 0; i < rows.length; i++) {
            var row = rows.item(i);
            tgh[i]=eval("row.TB"+Ind);                            
        }
    }    
    return tgh;
}

 

 

 

_________________________________________
www.jasonmace.com/blackberry