function GETLatestValue() {
var sheet = SpreadsheetApp.getActiveSheet();
var data = sheet.getDataRange().getValues();
for (var i = 1; i < data.length; i++) {
Logger.log('PN: ' + data[i][0]);
//Logger.log('Product number: ' + data[i][1]);
var sql = 'SELECT * FROM 1Ynn6Jt34YaPV7ojdJNrp9sXoHTqLWRCIBaOKbpCZ WHERE PN_ID = ' + data[i][0] + ' LIMIT 1';
Logger.log(sql);
var result = FusionTables.Query.sqlGet(sql, {
hdrs: false
});
Logger.log(result.rows);
if (result.rows) {
//data(i,1).setValue(evento[i]);
Logger.log('rows[0][2]: %s', result.rows[0][2]);
Logger.log('rows[0][3]: %s', result.rows[0][3]);
//data[i][1] result.rows[0][2];
sheet.getRange(i+1,2).setValue(result.rows[0][2]);
sheet.getRange(i+1,3).setValue(result.rows[0][3]);
}
}
/*
var sql = 'SELECT * FROM 1Ynn6Jt34YaPV7ojdJNrp9sXoHTqLWRCIBaOKbpCZ WHERE LIMIT 1000';
Logger.log(sql);
var result = FusionTables.Query.sqlGet(sql, {
hdrs: false
});
Logger.log(resultrows);
if (result.rows) {
Logger.log('Query results spreadsheet created: %s', result.rows[0][Column_No]);
} else {
Logger.log('No rows returned.');
}
*/
}
Comments
Post a Comment