title: How to make a WebSQL query synchronous?
body: <p>Consider:</p>
  
  <pre><code>var globalvar;
  
  function viewyearmain() {
    db.transaction(function (tx) 
    {
      tx.executeSql('SELECT * FROM BUDGET WHERE holdingtype="month"', [], function (tx, results) 
      {
         var len = results.rows.length;
         msg = len;
         globalvar = msg;
      }, null);
  
    });
  
    if (globalvar&gt;0)
    {
      alert("ROWS FOUND");
    }
    else
    {
      alert("ROWS NOT FOUND");
    }
  }
  </code></pre>
  
  <p>The problem is that <code>ROWS NOT FOUND</code> appears because the transaction has not completed by the time the <code>if</code> statement is reached.</p>