javascript - issue with loop the select query in sqlite? -


I am trying to iterate a dynamic array as the input for the selected query. The selected query for all the array elements is not firing. I wrote a selected query for the loop, the problem loop is already firing and the selection query is only performing for the last element of the array. This can be due to asynchronous function. How can I fix this, my code is as follows,

  function sendCategoryDetailsNew (myLocation) {var myLocationcoordinates = new array (); Var db = window sqlite plugin.openDatabase ({name: "MYDB"}); For (var i = 0; i   

Any suggestion,

simplifying the code Try to think that for this issue, is going to with .

Here is an example of how I will try: function sendCategoryDetailsNew (myLocation) {var myLocationcoordinates = new array (); Var db = window sqlite plugin.openDatabase ({name: "MYDB"}); Var locationsList = "\" "+ myLocation.join (" \ ', \' ") +" \ '"db.transaction (function (tx) {tx.executeSql (" Select location, coordinates from location location ("Location:"), "list of locations, function (tx, ridge) {for (var i = 0; i & lt; res.rows .length; i ++) {console.log (" location: "+ res.rows.item (i). location + "lateong:" + res.rows.item (i) coordinate); myLocationcoordinates [i] = res lines .atom (i) .Cordinates;}})}}

Instead of looping through two sets of values, I have compiled the myLocation string using the IN in sql statement. It will return all the results for the myLocation array and then it will be repeated by them for processing.

This reduces many resources And also creates fewer failed points in the function.

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -