0

I've got the following function on my client-side db:

      dropTable = function (a, tbl) {
        a.executeSql('Drop Table If Exists ' + tbl + ';', [], 
          function(a, b){
            console.log('Table "' + tbl + '" dropped.');
          }
        , errorHandler);
      };

What do I have to do to show the console message only when a table is dropped? It currently shows on every function call.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
DataZombies
  • 416
  • 6
  • 19

1 Answers1

1

Looks like your query is "successful" whether it exists or not (since you guard for the case of nonexistence). If you want to fail hard:

     dropTable = function (a, tbl) {
        a.executeSql('Drop Table ' + tbl + ';', [], 
          function(a, b){
            console.log('Table "' + tbl + '" dropped.');
          }
        , errorHandler);
      };

This should call the errorHandler if it doesn't exist. Cheers!

Stefan Mai
  • 23,367
  • 6
  • 55
  • 61