title: How can I fetch data synchronously from cordova-sqlite?
body: <h2>Is it possible to fetch data synchronously from cordova-sqlite?</h2>
  
  <p>I have a table <code>caseTable</code> with fields (ID, caseName, date). Each row in that table corresponds to another table named after the caseName field. I need to loop through the <code>caseTable</code> table and get a count of the number of rows in the table referred to.</p>
  
  <pre><code>function onDeviceReady() {
      db = window.openDatabase("Casepad", "1.0", "Casepad", 200000);
      db.transaction(getallTableData, errorCB);    
  }
  
  function insertData() {
      db.transaction(createTable, errorCB, afterSuccessTableCreation);
  }
  
  // create table and insert some record
  function createTable(tx) {
      tx.executeSql('CREATE TABLE IF NOT EXISTS CaseTable (id INTEGER PRIMARY KEY AUTOINCREMENT, CaseName  TEXT unique NOT NULL ,CaseDate INTEGER ,TextArea TEXT NOT NULL)');
  
      tx.executeSql('INSERT OR IGNORE INTO CaseTable(CaseName,CaseDate,TextArea) VALUES ("' + $('.caseName_h').val() + '", "' + $('.caseDate_h').val() + '","' + $('.caseTextArea_h').val() + '")');
  
  
  }
  // function will be called when an error occurred
  function errorCB(err) {
      navigator.notification.alert("Error processing SQL: " + err.code);
  }
  
  // function will be called when process succeed
  function afterSuccessTableCreation() {
      console.log("success!");
      db.transaction(getallTableData, errorCB);
  }
  
  
  // select all from SoccerPlayer
  function getallTableData(tx) {
      tx.executeSql('SELECT * FROM CaseTable', [], querySuccess, errorCB);
  }
  
  
  function querySuccess(tx, result) {
      var len = result.rows.length;
      var t;
      $('#folderData').empty();
      for (var i = 0; i &lt; len; i++) {
          /* *************************************************************
           * Here i need to call a synchronous method which returns the
           * number of rows in the result.rows.item(i).CaseName table 
           * ************************************************************* */
          $('#folderData').append(
                  '&lt;li class="caseRowClick" id="' + result.rows.item(i).id + '" data-rel="popup" data-position-to="window"&gt;' + '&lt;a href="#"&gt;' + '&lt;img src="img/Blue-Folder.png"&gt;' + '&lt;h2&gt;' + result.rows.item(i).CaseName + t+'&lt;/h2&gt;' + '&lt;p&gt;' + result.rows.item(i).TextArea + '&lt;/p&gt;' + '&lt;p&gt;' + result.rows.item(i).CaseDate + '&lt;/p&gt;' + '&lt;span class="ui-li-count"&gt;' + i + '&lt;/span&gt;&lt;/a&gt;' + 
                   '&lt;span class="ctrl togg"&gt;&lt;fieldset data-role="controlgroup" data-type="horizontal" data-mini="true" &gt;&lt;button class="edit button_design"&gt;Edit&lt;/button&gt;&lt;button class="del button_design"&gt;Delete&lt;/button&gt;&lt;/fieldset&gt;&lt;span&gt;'+'&lt;/li&gt;'
                  );
      }
      $('#folderData').listview('refresh');
  
  }
  </code></pre>
  
  <p>Instend of showing value of "i" in list view i need to show how many element in that table . I need to call synchronise because i need to call some query which count the number of element in "result.rows.item(i).CaseName" in this element..?</p>
  
  <p>Take Example ...</p>
  
  <p>DB Name <strong>Case Pad</strong>
  Table Name CaseTable </p>
  
  <pre><code>    Let assume having entries in caseTable.
  
  
        ID      CaseName      Case Date   caseNote
          1         Test           3/77/13   jgjgj
          2         Test2          4/34/3   hsadkkadsh 
  
  
  Now I have two more table in DB
  Test , Test2..
  
      **Test** having entries like this
  
         ID          DocumentName    Date         Notes
         1)           ppp              7/33         asdhdfkdshf
         2)           asdjhad            9/44       dfjasgfsjfj
      **Test2** having entries like this
  
         ID          DocumentName    Date         Notes
         1)           sad            7/4         asdhdfkdshf
         2)           assd           3/44          hhhhhh
         3)            asd           2/22          adgjad
  </code></pre>
  
  <p>Now Test , Test2 have entry is 2 and 3.</p>
  
  <p>Now i need to fetch data of CaseTable .While fetch i need to count Number of element in my casename table (Test, Test1). here only</p>
  
  <pre><code> function getallTableData(tx) {
          tx.executeSql('SELECT * FROM CaseTable', [], querySuccess, errorCB);
      }
  
  
  
      function querySuccess(tx, result) {
          var len = result.rows.length;
          var t;
          $('#folderData').empty();
          for (var i = 0; i &lt; len; i++) {
      Here i need to call synchronize method which call the number of element in in that  result.rows.item(i).CaseName and insert it in this table
      ****************************************************************************
              $('#folderData').append(
                      '&lt;li class="caseRowClick" id="' + result.rows.item(i).id + '" data-rel="popup" data-position-to="window"&gt;' + '&lt;a href="#"&gt;' + '&lt;img src="img/Blue-Folder.png"&gt;' + '&lt;h2&gt;' + result.rows.item(i).CaseName + t+'&lt;/h2&gt;' + '&lt;p&gt;' + result.rows.item(i).TextArea + '&lt;/p&gt;' + '&lt;p&gt;' + result.rows.item(i).CaseDate + '&lt;/p&gt;' + '&lt;span class="ui-li-count"&gt;' + i + '&lt;/span&gt;&lt;/a&gt;' + 
                       '&lt;span class="ctrl togg"&gt;&lt;fieldset data-role="controlgroup" data-type="horizontal" data-mini="true" &gt;&lt;button class="edit button_design"&gt;Edit&lt;/button&gt;&lt;button class="del button_design"&gt;Delete&lt;/button&gt;&lt;/fieldset&gt;&lt;span&gt;'+'&lt;/li&gt;'
                      );
          }
          $('#folderData').listview('refresh');
  
      }
  </code></pre>
  
  <p><strong>I need to Print casename casedate case Note ,number of elements</strong>
  So my list is look like this</p>
  
  <pre><code> Test           3/77/13   jgjgj      2
   Test2          4/34/3   hsadkkadsh  3
  </code></pre>
  
  <p>How to print 2 and 3 in that table...:( can you please give me any query)</p>