html5 - nested Sqlite Query not working properly -


in code outer sqlite query first finish work goes inner sqlite query please explain me why happen , give solution of requirment.

/*outer sqlite query*/  db.transaction(function(transaction){  transaction.executesql('select * outertable;', [],   function(transaction,results){    if (results != null && results.rows != null) {       (var = 0; < results.rows.length; i++) {       /*my work going here*/                      /*inner sqlite query   inside lor loop*/        db.transaction(function(transaction){            transaction.executesql('select * myinnertable;',[],    function(transaction, result){    if (result != null && result.rows != null)  {                                             (var j = 0; j < result.rows.length; j++) {               /* work going here */            }             }      },errorhandler);      } ,errorhandler,nullhandler);        /*inner sqlite end here*/                                          }                       }                    },errorhandler);                   }                   ,errorhandler,nullhandler);            /*outer sqlite end here*/   

the problem here
first---> outer sqlite work executing inner sqlite work executing requirment each value of outer sqlite inner sqlite work

for example:--

for(int i=0;i<=10;i++){      for(int j=0;j<=10;j++){    // here inner loop work every value of outer loop     }  }  

thanks in advance

your requirement perform inner query every outer query cannot achieved this. since select queries async calls.

even outer loop doesn't wait query @ previous index completed. continue execution , simultaneously fire select queries.

however, achieve can use recursion.

where each outer loop calls select query, success callback implements inner query , success callback of inner query recursively calls inner query required number of times required index , post number of times (inner loop condition) call outer query implementer incremented index.

hope helps.


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -