mardi 15 septembre 2015

db.transaction inside results

I want to run a transaction inside results function for each result. The 2nd transaction will run another query with primary key passed from 1st transaction result, but i can't make it worked and it throw error.

This is my main query

db.transaction(function(tx) {
   tx.executeSql('SELECT * FROM Drinks', 
                 [],
                 function(tx, results)
                 {
                   db.transaction(selectStatement, errorCB); //this line got error
                 },
                 function(tx, error)
                 {

                 }
   );
});

And for the second transaction was put it outside because it will be used everywhere. But i dont know how to call it in transaction with parameter drink_id

function selectStatement(tx,drink_id) {
    tx.executeSql('SELECT * FROM flavour where drink_id=?', [drink_id], 
function (tx, results) {...}, errorCB);
}

Aucun commentaire:

Enregistrer un commentaire