0

I'd like to create a javascript function that returns an SQLite record value.

But how can I solve the scope?

function LeeSQLite() {
  var valor = "";
  var myDB = window.sqlitePlugin.openDatabase({
    name: 'myDB.db',
    location: 'default'
  });
  myDB.transaction(function(transaction) {
    var SQL = "SELECT desc FROM user_table WHERE id = 1";
    transaction.executeSql(SQL, [], function(tx, results) {
      valor = results.rows.item(0).desc;
    }, null);
  });
  return valor;
}
mplungjan
  • 169,008
  • 28
  • 173
  • 236
Carlos
  • 1
  • 1
  • 1
    @PraveshAgrawa: You should be removing messages like "Thanks" from questions... not adding them. –  Sep 24 '16 at 16:28
  • 1
    @squint I think he edited at the same time as I did. – mplungjan Sep 24 '16 at 16:29
  • 1
    @mplungjan: Oh, I see. He was squashing your edit. Well that's another matter I guess. –  Sep 24 '16 at 16:30

0 Answers0