How put data from http request to database and list

Hi i need to put data from JSON object(take from a http request) to table of database and in a list…how can i do that??

$scope.chiamataUno = function() {
    var authdata = Base64.encode("xxx" + ":" + "xxx");
    $http.defaults.headers.common["Authorization"] = "Basic " + authdata;
    $http.get('http://demvsint-as1-sd.services.eni.intranet:8001/CaseManager/P8BPMREST/p8/bpm/v1/queues/DV_ResponsabileBSDL/workbaskets/Responsabile BSDL/queueelements/?cp=DCMSVS_CONN1').success(function(response) {
               console.log(response);
               
     
              $rootScope.risposta = response;
                                        
              $rootScope.responseJSON = JSON.stringify($scope.risposta);

        var newArray = [];
        for(var i=0;i<response.queueElements.length;i++){
        newObject = {
          caseFolderId:response.queueElements[i].caseFolderId,
          caseTaskId:response.queueElements[i].caseTaskId,
          stepName:response.queueElements[i].stepName,
          columns:response.queueElements[i].columns,
          DV_Caseidentifier_for_eni_OdA: response.queueElements[i].columns.DV_Caseidentifier_for_eni_OdA,
          DV_EBELP_ODA: response.queueElements[i].columns.DV_EBELP_ODA,
          DV_EINDT_ODA: response.queueElements[i].columns.DV_EINDT_ODA,
          DV_MATNR_TXZ01_POS_ODA: response.queueElements[i].columns.DV_MATNR_TXZ01_POS_ODA,
          DV_NAMECL_POS_ODA: response.queueElements[i].columns.DV_NAMECL_POS_ODA,
          DV_NETPR_WAERS_POS_ODA: response.queueElements[i].columns.DV_NETPR_WAERS_POS_ODA,
          DV_PEINH_POS: response.queueElements[i].columns.DV_PEINH_POS,
          DV_MENGE_MEINS_POS_ODA: response.queueElements[i].columns.DV_MENGE_MEINS_POS_ODA
        };
       newArray.push(newObject);

        console.log("dettaglio " + newObject.DV_MENGE_MEINS_POS_ODA + " " + newObject.stepName + " " + newObject.DV_EINDT_ODA);
      
          $rootScope.newObjectJSON = JSON.stringify(newObject);

    if(newObject.length > 0) {
     for(var i = 0; i < newObject.length; i++) {
        var queryOdl = "INSERT INTO Tabella_OdL (caseTaskId, caseFolderId, DV_Caseidentifier_for_eni_OdA,DV_EBELP_ODA,DV_EINDT_ODA,DV_MATNR_TXZ01_POS_ODA,DV_NAMECL_POS_ODA,DV_NETPR_WAERS_POS_ODA,DV_PEINH_POS,DV_MENGE_MEINS_POS_ODA) VALUES (?,?,?,?,?,?,?,?,?,?) WHERE stepName = 'Item details'";
          $cordovaSQLite.execute(db, queryOdl, [newObject.caseFolderId, newObject.caseTaskId,newObject.stepName,newObject.DV_Caseidentifier_for_eni_OdA,newObject.DV_EBELP_ODA,newObject.DV_EINDT_ODA,newObject.DV_MATNR_TXZ01_POS_ODA,newObject.DV_NAMECL_POS_ODA,newObject.DV_NETPR_WAERS_POS_ODA,newObject.DV_PEINH_POS,newObject.DV_MENGE_MEINS_POS_ODA]);
            console.log("insert ODL");
    }
  }else{
  console.log("nessun oggetto");
  }
        $scope.newObject = newObject;
            $rootScope.allODLJSON = JSON.stringify($scope.newObject);
            var allODLJSON = $rootScope.allODLJSON;
            console.log("json newObject" + allODLJSON);   
        }
            })
            .error(function(response) {
                alert("ERROR");
            });
    }
1 Like

Post full code and I’ll fix it. This is partial code, I can’t see what you are trying to do. I can see many errors though.

See my attempt to draw your attention to some errors below:

 $scope.chiamataUno = function() {

 var authdata = Base64.encode("xxx" + ":" + "xxx");

 $http.defaults.headers.common["Authorization"] = "Basic " + authdata;

 $http.get('http://demvsint-as1-sd.services.eni.intranet:8001/CaseManager/P8BPMREST/p8/bpm/v1/queues/DV_ResponsabileBSDL/workbaskets/Responsabile BSDL/queueelements/?cp=DCMSVS_CONN1')
 .success(function(response) {

         console.log(response);

         $rootScope.risposta = response;

         $rootScope.responseJSON = JSON.stringify($scope.risposta);

         var newArray = [];
         
         $rootScope.newObjectJSON = [];
         
         $scope.newObject = [];
         
         for (var i = 0; i < response.queueElements.length; i++) {
            //missed var from newObject below
             var newObject = {
                 caseFolderId: response.queueElements[i].caseFolderId,
                 caseTaskId: response.queueElements[i].caseTaskId,
                 stepName: response.queueElements[i].stepName,
                 columns: response.queueElements[i].columns,
                 DV_Caseidentifier_for_eni_OdA: response.queueElements[i].columns.DV_Caseidentifier_for_eni_OdA,
                 DV_EBELP_ODA: response.queueElements[i].columns.DV_EBELP_ODA,
                 DV_EINDT_ODA: response.queueElements[i].columns.DV_EINDT_ODA,
                 DV_MATNR_TXZ01_POS_ODA: response.queueElements[i].columns.DV_MATNR_TXZ01_POS_ODA,
                 DV_NAMECL_POS_ODA: response.queueElements[i].columns.DV_NAMECL_POS_ODA,
                 DV_NETPR_WAERS_POS_ODA: response.queueElements[i].columns.DV_NETPR_WAERS_POS_ODA,
                 DV_PEINH_POS: response.queueElements[i].columns.DV_PEINH_POS,
                 DV_MENGE_MEINS_POS_ODA: response.queueElements[i].columns.DV_MENGE_MEINS_POS_ODA
             };
             
             newArray.push(newObject);

             console.log("dettaglio " + newObject.DV_MENGE_MEINS_POS_ODA + " " + newObject.stepName + " " + newObject.DV_EINDT_ODA);

 // this gets changed everytime the loop runs so will end with the value from the last loop as rootscope is defined outside the scope of the function, push to an array if you want to retain all results in the loop, have changed it. See creation of array above.
             $rootScope.newObjectJSON.push(JSON.stringify(newObject));
             //$rootScope.newObjectJSON = JSON.stringify(newObject);

             if (newObject.length > 0) {
                 for (var i = 0; i < newObject.length; i++) {
                     var queryOdl = "INSERT INTO Tabella_OdL (caseTaskId, caseFolderId, DV_Caseidentifier_for_eni_OdA,DV_EBELP_ODA,DV_EINDT_ODA,DV_MATNR_TXZ01_POS_ODA,DV_NAMECL_POS_ODA,DV_NETPR_WAERS_POS_ODA,DV_PEINH_POS,DV_MENGE_MEINS_POS_ODA) VALUES (?,?,?,?,?,?,?,?,?,?) WHERE stepName = 'Item details'";
                     $cordovaSQLite.execute(db, queryOdl, [newObject.caseFolderId, newObject.caseTaskId, newObject.stepName, newObject.DV_Caseidentifier_for_eni_OdA, newObject.DV_EBELP_ODA, newObject.DV_EINDT_ODA, newObject.DV_MATNR_TXZ01_POS_ODA, newObject.DV_NAMECL_POS_ODA, newObject.DV_NETPR_WAERS_POS_ODA, newObject.DV_PEINH_POS, newObject.DV_MENGE_MEINS_POS_ODA]);
                     console.log("insert ODL");
                 };
             } else {
                 console.log("nessun oggetto");
             }
             
             // this gets changed everytime the loop runs so will end with the value from the last loop as $scope is defined outside the scope of the function, push to an array if you want to retain all results in the loop, have changed it.  See creation of array above.
             $scope.newObject.push(JSON.stringify(newObject));
             //$scope.newObject = newObject;
             
             // not sure what you are trying to do do here
             $rootScope.allODLJSON = JSON.stringify($scope.newObject);
             
             var allODLJSON = $rootScope.allODLJSON;
             console.log("json newObject" + allODLJSON);
         }
     })
     .error(function(response) {
         alert("ERROR");
     });
     }

    //this is refering to multiple variables with this name which are specific to the previous function and as such are not accessable outside the function, this won't work
    $scope.newObject = newObject;
    $rootScope.allODLJSON = JSON.stringify($scope.newObject);

    var allODLJSON = $rootScope.allODLJSON;
    console.log("json newObject" + allODLJSON);
1 Like

hi,first of all thank you all…ok I make the request and i can get the data from json, also i can show in a log all the data, but i’m unable to put data into a database and show it in a list, the code never go into the if of the insert…for example

    console.log("columns oggetto DV_EBELP_ODA " + newObject.columns.DV_EBELP_ODA);
    console.log("columns oggetto DV_EINDT_ODA " + newObject.columns.DV_EINDT_ODA);
    console.log("Queue Elements oggetto caseFolderId " + newObject.caseFolderId);
    console.log("Queue Elements oggetto caseTaskId " + newObject.caseTaskId);
    console.log("Queue Elements oggetto stepName " + newObject.stepName);

and after put in a table with an insert and show it in a list with a ng-init in the html

var queryB = “SELECT * FROM Tabella_OdL”;
$rootScope.allODL = [];
$cordovaSQLite.execute(db, queryB, []).then(function(res) {
if(res.rows.length > 0) {

            for(var i = 0; i < res.rows.length; i++) {
                 
               $rootScope.allODL.push({
                caseTaskId: res.rows.item(i).caseTaskId,
                caseFolderId: res.rows.item(i).caseFolderId,     
                stepName: res.rows.item(i).stepName,
                DV_Caseidentifier_for_eni_OdA: res.rows.item(i).DV_Caseidentifier_for_eni_OdA,
                DV_EBELP_ODA: res.rows.item(i).DV_EBELP_ODA,
                DV_EINDT_ODA: res.rows.item(i).DV_EINDT_ODA,
                DV_NETPR_WAERS_POS_ODA: res.rows.item(i).DV_NETPR_WAERS_POS_ODA,
                DV_MENGE_MEINS_POS_ODA: res.rows.item(i).DV_MENGE_MEINS_POS_ODA,
                DV_MATNR_TXZ01_POS_ODA: res.rows.item(i).DV_MATNR_TXZ01_POS_ODA,
                DV_PEINH_POS: res.rows.item(i).DV_PEINH_POS,
                DV_NAMECL_POS_ODA: res.rows.item(i).DV_NAMECL_POS_ODA,       
                });

              $rootScope.allODLJSON = JSON.stringify($rootScope.allODL);
             //console.log("json Tabella_OdL" + JSON.stringify($rootScope.allODL));
            }
        } else {
            console.log("No results found ODL");
        }
    }, function (err) {
        console.error(err);
    });

HTML example
div ng-init="chiamataUno()"
ion-item class=“wrapword” ng-repeat=“object in allODL”

{{object.DV_MENGE_MEINS_POS_ODA}}/span

if i try to use insert and select…23 insert but after no resoult found!!!

dati json array undefined is nothing usefull…just delete after

if($rootScope.newObjectJSON.length > 0) {
for(var i = 0; i < $rootScope.newObjectJSON.length; i++) {
var queryOdl = “INSERT INTO Tabella_OdL (caseTaskId, caseFolderId, DV_Caseidentifier_for_eni_OdA,DV_EBELP_ODA,DV_EINDT_ODA,DV_MATNR_TXZ01_POS_ODA,DV_NAMECL_POS_ODA,DV_NETPR_WAERS_POS_ODA,DV_PEINH_POS,DV_MENGE_MEINS_POS_ODA) VALUES (?,?,?,?,?,?,?,?,?,?) WHERE stepName = ‘Item details’”;

      $cordovaSQLite.execute(db, queryOdl, [newObject.caseFolderId, 

newObject.caseTaskId,newObject.stepName,newObject.DV_Caseidentifier_for_eni_OdA,newObject.DV_

EBELP_ODA,newObject.DV_EINDT_ODA,newObject.DV_MATNR_TXZ01_POS_ODA,newObject.DV_N

AMECL_POS_ODA,newObject.DV_NETPR_WAERS_POS_ODA,newObject.DV_PEINH_POS,newObject

.DV_MENGE_MEINS_POS_ODA]);
console.log(“insert ODL”);
}
}else{
console.log(“nessun oggetto”);
}

    var queryB = "SELECT * FROM Tabella_OdL";
    $rootScope.allODL = [];
    $cordovaSQLite.execute(db, queryB, []).then(function(res) {
        if(res.rows.length > 0) {
           
            for(var i = 0; i < res.rows.length; i++) {
                 
               $rootScope.allODL.push({
                caseTaskId: res.rows.item(i).caseTaskId,
                caseFolderId: res.rows.item(i).caseFolderId,     
                stepName: res.rows.item(i).stepName,
                DV_Caseidentifier_for_eni_OdA: res.rows.item(i).DV_Caseidentifier_for_eni_OdA,
                DV_EBELP_ODA: res.rows.item(i).DV_EBELP_ODA,
                DV_EINDT_ODA: res.rows.item(i).DV_EINDT_ODA,
                DV_NETPR_WAERS_POS_ODA: res.rows.item(i).DV_NETPR_WAERS_POS_ODA,
                DV_MENGE_MEINS_POS_ODA: res.rows.item(i).DV_MENGE_MEINS_POS_ODA,
                DV_MATNR_TXZ01_POS_ODA: res.rows.item(i).DV_MATNR_TXZ01_POS_ODA,
                DV_PEINH_POS: res.rows.item(i).DV_PEINH_POS,
                DV_NAMECL_POS_ODA: res.rows.item(i).DV_NAMECL_POS_ODA,       
                });

              $rootScope.allODLJSON = JSON.stringify($rootScope.allODL);
             //console.log("json Tabella_OdL" + JSON.stringify($rootScope.allODL));
            }
        } else {
            console.log("No results found ODL");
        }
    }, function (err) {
        console.error(err);
    });

Try this:

$scope.chiamataUno = function() {

 var authdata = Base64.encode("xxx" + ":" + "xxx");

 $http.defaults.headers.common["Authorization"] = "Basic " + authdata;

 $http.get('http://demvsint-as1-sd.services.eni.intranet:8001/CaseManager/P8BPMREST/p8/bpm/v1/queues/DV_ResponsabileBSDL/workbaskets/Responsabile BSDL/queueelements/?cp=DCMSVS_CONN1')
 .success(function(response) {

	$rootScope.resultsArrayForHTML = []; // this is displayed in the HTML using ng-repeat, see below
 
	 for (var i = 0; i < response.queueElements.length; i++) {
		//missed var from newObject below
		 var newObject = {
			 caseFolderId: response.queueElements[i].caseFolderId,
			 caseTaskId: response.queueElements[i].caseTaskId,
			 stepName: response.queueElements[i].stepName,
			 columns: response.queueElements[i].columns,
			 DV_Caseidentifier_for_eni_OdA: response.queueElements[i].columns.DV_Caseidentifier_for_eni_OdA,
			 DV_EBELP_ODA: response.queueElements[i].columns.DV_EBELP_ODA,
			 DV_EINDT_ODA: response.queueElements[i].columns.DV_EINDT_ODA,
			 DV_MATNR_TXZ01_POS_ODA: response.queueElements[i].columns.DV_MATNR_TXZ01_POS_ODA,
			 DV_NAMECL_POS_ODA: response.queueElements[i].columns.DV_NAMECL_POS_ODA,
			 DV_NETPR_WAERS_POS_ODA: response.queueElements[i].columns.DV_NETPR_WAERS_POS_ODA,
			 DV_PEINH_POS: response.queueElements[i].columns.DV_PEINH_POS,
			 DV_MENGE_MEINS_POS_ODA: response.queueElements[i].columns.DV_MENGE_MEINS_POS_ODA
		 };
	 
		 $rootScope.resultsArrayForHTML.push(newObject);

		 console.log("dettaglio " + newObject.DV_MENGE_MEINS_POS_ODA + " " + newObject.stepName + " " + newObject.DV_EINDT_ODA);

		// insert data into table

		 var queryOdl = "INSERT INTO Tabella_OdL (caseTaskId, caseFolderId, DV_Caseidentifier_for_eni_OdA,DV_EBELP_ODA,DV_EINDT_ODA,DV_MATNR_TXZ01_POS_ODA,DV_NAMECL_POS_ODA,DV_NETPR_WAERS_POS_ODA,DV_PEINH_POS,DV_MENGE_MEINS_POS_ODA) VALUES (?,?,?,?,?,?,?,?,?,?) WHERE stepName = 'Item details'";
		 $cordovaSQLite.execute(db, queryOdl, [newObject.caseFolderId, newObject.caseTaskId, newObject.stepName, newObject.DV_Caseidentifier_for_eni_OdA, newObject.DV_EBELP_ODA, newObject.DV_EINDT_ODA, newObject.DV_MATNR_TXZ01_POS_ODA, newObject.DV_NAMECL_POS_ODA, newObject.DV_NETPR_WAERS_POS_ODA, newObject.DV_PEINH_POS, newObject.DV_MENGE_MEINS_POS_ODA]);
		 console.log("insert ODL");

	 }
	 
 })
 .error(function(response) {
	 alert("Http ERROR");
 });
 };

Use $rootScope.resultsArrayForHTML for your ng-repeat.

1 Like

hi… i used this
$rootScope.newObjectJSON.push(JSON.stringify(newObject));

and this

if($rootScope.newObjectJSON.length > 0) {
for(var i = 0; i < $rootScope.newObjectJSON.length;i++) {
var queryOdl = “INSERT INTO Tabella_OdL (caseTaskId, caseFolderId, stepName, DV_Caseidentifier_for_eni_OdA,DV_EBELP_ODA,DV_EINDT_ODA,DV_MATNR_TXZ01_POS_ODA,DV_NAMECL_POS_ODA,DV_NETPR_WAERS_POS_ODA,DV_PEINH_POS,DV_MENGE_MEINS_POS_ODA) VALUES (?,?,?,?,?,?,?,?,?,?,?)”;
$cordovaSQLite.execute(db, queryOdl, [newObject.caseFolderId, newObject.caseTaskId,newObject.stepName, newObject.DV_Caseidentifier_for_eni_OdA,newObject.DV_EBELP_ODA,newObject.DV_EINDT_ODA,newObject.DV_MATNR_TXZ01_POS_ODA,newObject.DV_NAMECL_POS_ODA,newObject.DV_NETPR_WAERS_POS_ODA,newObject.DV_PEINH_POS,newObject.DV_MENGE_MEINS_POS_ODA]);
console.log(“insert ODL”);//mi da sempre lo stesso
}
}else{
console.log(“nessun oggetto”);
}
/*
console.log(“INIZIO OGGETTO”);
console.log("Queue Elements oggetto caseFolderId " + newObject.caseFolderId);
console.log("columns oggetto DV_MENGE_MEINS_POS_ODA " + newObject.columns.DV_MENGE_MEINS_POS_ODA);
console.log(“FINE OGGETTO”);
*/

    }//fine for
    var queryB = "SELECT * FROM Tabella_OdL";
    $rootScope.allODL = [];
    $cordovaSQLite.execute(db, queryB, []).then(function(res) {
        if(res.rows.length > 0) {
           
            for(var i = 0; i < res.rows.length; i++) {
                 
               $rootScope.allODL.push({
                caseTaskId: res.rows.item(i).caseTaskId,
                caseFolderId: res.rows.item(i).caseFolderId,     
                stepName: res.rows.item(i).stepName,
                DV_Caseidentifier_for_eni_OdA: res.rows.item(i).DV_Caseidentifier_for_eni_OdA,
                DV_EBELP_ODA: res.rows.item(i).DV_EBELP_ODA,
                DV_EINDT_ODA: res.rows.item(i).DV_EINDT_ODA,
                DV_NETPR_WAERS_POS_ODA: res.rows.item(i).DV_NETPR_WAERS_POS_ODA,
                DV_MENGE_MEINS_POS_ODA: res.rows.item(i).DV_MENGE_MEINS_POS_ODA,
                DV_MATNR_TXZ01_POS_ODA: res.rows.item(i).DV_MATNR_TXZ01_POS_ODA,
                DV_PEINH_POS: res.rows.item(i).DV_PEINH_POS,
                DV_NAMECL_POS_ODA: res.rows.item(i).DV_NAMECL_POS_ODA,       
                });

              $rootScope.allODLJSON = JSON.stringify($rootScope.allODL);
             //console.log("json Tabella_OdL" + JSON.stringify($rootScope.allODL));
            }
        } else {
            console.log("No results found ODL");
        }
        $ionicLoading.hide();
    }, function (err) {
        console.error(err);
    });
        })
        .error(function(response) {
            alert("ERROR");
        });

        //fine chiamataUno
}

and this

ng-repeat=“object in allODL”

and worked!! thank you all…now i’m tring to use a spinner for the load

ok great, the problem was this…

         if (newObject.length > 0) {
             for (var i = 0; i < newObject.length; i++) {
                 var queryOdl = "INSERT INTO Tabella_OdL (caseTaskId, caseFolderId, DV_Caseidentifier_for_eni_OdA,DV_EBELP_ODA,DV_EINDT_ODA,DV_MATNR_TXZ01_POS_ODA,DV_NAMECL_POS_ODA,DV_NETPR_WAERS_POS_ODA,DV_PEINH_POS,DV_MENGE_MEINS_POS_ODA) VALUES (?,?,?,?,?,?,?,?,?,?) WHERE stepName = 'Item details'";
                 $cordovaSQLite.execute(db, queryOdl, [newObject.caseFolderId, newObject.caseTaskId, newObject.stepName, newObject.DV_Caseidentifier_for_eni_OdA, newObject.DV_EBELP_ODA, newObject.DV_EINDT_ODA, newObject.DV_MATNR_TXZ01_POS_ODA, newObject.DV_NAMECL_POS_ODA, newObject.DV_NETPR_WAERS_POS_ODA, newObject.DV_PEINH_POS, newObject.DV_MENGE_MEINS_POS_ODA]);
                 console.log("insert ODL");
             };
         } else {
             console.log("nessun oggetto");
         }

Objects {} in javascript do not have length properties so the if statement would return false. Arrays [] do have a length property. If you need to query object ‘lengths’ you can use

var myObject = {}; 
var objectLength = Object.keys(myObject).length;

Thanks, glad it’s working

oh…but it’s working…maybe i can have problem with the insert in the table, because if i restart the app there’s nothing in the db…ok i’ll try boss… Thank you so much!!!

Have you got this code in there?:

var db = $cordovaSQLite.openDB({ name: 'app.db' }); // put your db name in here

$cordovaSQLite.execute(db,"CREATE TABLE IF NOT EXISTS Tabella_OdL (caseTaskId, caseFolderId, stepName, DV_Caseidentifier_for_eni_OdA,DV_EBELP_ODA,DV_EINDT_ODA,DV_MATNR_TXZ01_POS_ODA,DV_NAMECL_POS_ODA,DV_NETPR_WAERS_POS_ODA,DV_PEINH_POS,DV_MENGE_MEINS_POS_ODA)");

If not put it just before:

for(var i = 0; i < $rootScope.newObjectJSON.length;i++) {

yes…it shuld be work…but for some reason doesn’t work…

db = $cordovaSQLite.openDB({name: “odl.db”, createFromLocation: 1});
console.log(db);

    $cordovaSQLite.execute(db, 'CREATE TABLE IF NOT EXISTS Tabella_OdL(caseTaskId TEXT, caseFolderId TEXT PRIMARY KEY, stepName TEXT, DV_Caseidentifier_for_eni_OdA TEXT, DV_EBELP_ODA TEXT, DV_EINDT_ODA TEXT,DV_NETPR_WAERS_POS_ODA TEXT, DV_MENGE_MEINS_POS_ODA TEXT, DV_MATNR_TXZ01_POS_ODA TEXT, DV_PEINH_POS TEXT, DV_NAMECL_POS_ODA TEXT)');

https://github.com/brodysoft/Cordova-SQLitePlugin.git

but there is some error somewhere…but i can’t understand

Any errors in the console?

No Content-Security-Policy meta tag found. Please add one when using the cordova-plugin-whitelist plugin. whitelist.js:23
Object
app.js:31
OPEN database: odl.db SQLitePlugin.js:174
SQLitePlugin
dbname: "odl.db"
openError: function (e) {
openSuccess: function () {
openargs: Object
proto: Object
app.js:119
new transaction is waiting for open operation SQLitePlugin.js:105
Uncaught TypeError: Cannot read property ‘Keyboard’ of undefined app.js:418
DB opened: odl.db SQLitePlugin.js:79
Doing login Object {username: “aaa”, password: “aaa”} controllers.js:97
path /odl controllers.js:157
No Content-Security-Policy meta tag found. Please add one when using the cordova-plugin-whitelist plugin.

maybe is this line
new transaction is waiting for open operation SQLitePlugin.js:105

Try this instead of your code and see what the log says:

$cordovaSQLite
.execute(db, queryOdl, [newObject.caseFolderId, newObject.caseTaskId,newObject.stepName, newObject.DV_Caseidentifier_for_eni_OdA,newObject.DV_EBELP_ODA,newObject.DV_EINDT_ODA,newObject.DV_MATNR_TXZ01_POS_ODA,newObject.DV_NAMECL_POS_ODA,newObject.DV_NETPR_WAERS_POS_ODA,newObject.DV_PEINH_POS,newObject.DV_MENGE_MEINS_POS_ODA])
.then(function(result) {
	console.log(JSON.stringify(result));
}, function(error) {
	console.error(JSON.stringify(error));
});

Object {rows: Object, rowsAffected: 1, insertId: 1}
app.js:525
No Content-Security-Policy meta tag found. Please add one when using the cordova-plugin-whitelist plugin. whitelist.js:25
Object {rows: Object, rowsAffected: 1, insertId: 2}
app.js:525
Object {message: “sqlite3_step failure: UNIQUE constraint failed: Tabella_OdL.caseFolderId”, code: 0} app.js:527
Object {rows: Object, rowsAffected: 1, insertId: 3}
app.js:525
Object {message: “sqlite3_step failure: UNIQUE constraint failed: Tabella_OdL.caseFolderId”, code: 0} app.js:527
Object {message: “sqlite3_step failure: UNIQUE constraint failed: Tabella_OdL.caseFolderId”, code: 0} app.js:527
Object {rows: Object, rowsAffected: 1, insertId: 4}
app.js:525
Object {message: “sqlite3_step failure: UNIQUE constraint failed: Tabella_OdL.caseFolderId”, code: 0} app.js:527
Object {message: “sqlite3_step failure: UNIQUE constraint failed: Tabella_OdL.caseFolderId”, code: 0} app.js:527
Object {message: “sqlite3_step failure: UNIQUE constraint failed: Tabella_OdL.caseFolderId”, code: 0} app.js:527
Object {rows: Object, rowsAffected: 1, insertId: 5}

the result…and so on for ever…in a infinite loop

You have specified “caseFolderId” as a primary key meaning that it must be unique, if this value is the same for any of the multiple inserts you are doing the write will fail. You could choose another variable in your data which is unique or add another column such as "id integer primary key,

    $cordovaSQLite.execute(db, 'CREATE TABLE IF NOT EXISTS Tabella_OdL(id integer primary key, caseTaskId TEXT, caseFolderId TEXT, stepName TEXT, DV_Caseidentifier_for_eni_OdA TEXT, DV_EBELP_ODA TEXT, DV_EINDT_ODA TEXT,DV_NETPR_WAERS_POS_ODA TEXT, DV_MENGE_MEINS_POS_ODA TEXT, DV_MATNR_TXZ01_POS_ODA TEXT, DV_PEINH_POS TEXT, DV_NAMECL_POS_ODA TEXT)')

yes…i check the json and made changes THANKS

i changed primary key with caseTaskId (it’s unique for every object … and i show data, but if restart all erased…with the same message

Object {rows: Object, rowsAffected: 1, insertId: 1}

Object {rows: Object, rowsAffected: 1, insertId: 2}

Object {message: “sqlite3_step failure: UNIQUE constraint failed: Tabella_OdL.caseTaskId”, code: 0}
Object {rows: Object, rowsAffected: 1, insertId: 3}

Object {message: “sqlite3_step failure: UNIQUE constraint failed: Tabella_OdL.caseTaskId”, code: 0}
Object {message: “sqlite3_step failure: UNIQUE constraint failed: Tabella_OdL.caseTaskId”, code: 0}
Object {rows: Object, rowsAffected: 1, insertId: 4}

Object {message: “sqlite3_step failure: UNIQUE constraint failed: Tabella_OdL.caseTaskId”, code: 0} Object {message: “sqlite3_step failure: UNIQUE constraint failed: Tabella_OdL.caseTaskId”, code: 0}
Object {message: “sqlite3_step failure: UNIQUE constraint failed: Tabella_OdL.caseTaskId”, code: 0}
Object {message: “sqlite3_step failure: UNIQUE constraint failed: Tabella_OdL.caseTaskId”, code: 0}
Object {message: “sqlite3_step failure: UNIQUE constraint failed: Tabella_OdL.caseTaskId”, code: 0}
Object {message: “sqlite3_step failure: UNIQUE constraint failed: Tabella_OdL.caseTaskId”, code: 0}
Object {message: “sqlite3_step failure: UNIQUE constraint failed: Tabella_OdL.caseTaskId”, code: 0}
Object {message: “sqlite3_step failure: UNIQUE constraint failed: Tabella_OdL.caseTaskId”, code: 0}
Object {message: “sqlite3_step failure: UNIQUE constraint failed: Tabella_OdL.caseTaskId”, code: 0}
Object {message: “sqlite3_step failure: UNIQUE constraint failed: Tabella_OdL.caseTaskId”, code: 0}
Object {message: “sqlite3_step failure: UNIQUE constraint failed: Tabella_OdL.caseTaskId”, code: 0}
Object {message: “sqlite3_step failure: UNIQUE constraint failed: Tabella_OdL.caseTaskId”, code: 0}
Object {message: “sqlite3_step failure: UNIQUE constraint failed: Tabella_OdL.caseTaskId”, code: 0}
Object {message: “sqlite3_step failure: UNIQUE constraint failed: Tabella_OdL.caseTaskId”, code: 0}
Object {rows: Object, rowsAffected: 1, insertId: 5}

ok…now i have data stored…but with the same error
Object {message: “sqlite3_step failure: UNIQUE constraint failed: Tabella_OdL.caseTaskId”, code: 0}

i change the ng-init…because before when i enter the page automatically i call the service …
But what is ths error?