angular – Loop taking only the first IONIC record 3

I need to compare the registered records without connection individually, with the registers of my webservice, if it exists it does Update, if it does not do Insert.
But my SQL query is only found in the first record, and it is falling in my IF and Else simultaneously.
Follow the function:

syncPayment (token, codven): Promise {
return new Promise ((resolves, reject) => {
this.getDB ()
.then ((db: SQLiteObject) => {

this.dataSync = this.http.get (syncURLPayment + & # 39; / & # 39; + token + & # 39; / & # 39; + codven, {headers: this.returnHeaders ()});
this.dataSync
.subscribe (data => {

(in the case of an error in the operating system), it is possible that the user can not access the database. & # 39 ;;

(var i de data.data) {
varcode = i.CODIGO;
var sqlSelect = "SELECT code, descri, tipoco, sincro, datint FROM dadf109 WHERE code =?";

db.executeSql (sqlSelect, [codigo])
.then ((result: any) => {
if (result.rows.length> 0) {
// check date of change, and update row
/*if(node.DATINT! = i.DATALT) {
var sqlUpd = & # 39; UPDATE dadf109 SET code = ?, described =?, typeco =?, sync =?, datint =? WHERE code =? & # 39 ;;

var arrayUpd = [i.codigo, i.descri, i.tipoco, 'S', i.DATALT, i.codigo];

db.executeSql (sqlUpd, arrayUpd)
.then (() => resolves (& # 39; OK & # 39;))
.catch (e => reject (e))
} * /
console.log (& # 39; if & # 39; + sqlSelect + code);
}} else {
/ * var ist = [i.CODIGO, i.DESCRI, i.TIPOCO, i.TAXMAX, i.INDACR, i.TIPIND, i.VALENT, i.PARA01, 'S', i.DATALT];

db.executeSql (sqlInsert, ist)
.then (() => resolves (& # 39; OK & # 39;))
.catch (e => reject (e)) * /
console.log (& # 39; else & # 39; + sqlSelect + code);
}
});
}
Resolved ()
});
}} catch (e => console.log (e));
});
}