title: How to run SELECT query ONLY AFTER the UPDATE queries have been completed in SQLite React Native?
body: <p>I have a program that performs the following logic:</p>
  <ol>
  <li>Select all saved rows in SQLite</li>
  <li>Send saved rows via API</li>
  <li>Update rows based on API response (status = uploaded / failed)</li>
  <li>Check if all rows are success, if yes then go to the next page.</li>
  </ol>
  <pre><code>var db = openDatabase({ name: 'test.db' });
  db.transaction(tx =&gt; {
      tx.executeSql(
          &quot;SELECT * FROM row_details WHERE offline_status == 'created' OR offline_status == 'updated'&quot;,
          [],
          (tx, results) =&gt; {
               let rows = [], message = '', totalRows = results.rows.length;
               for (let i = 0; i &lt; totalRows; i++) {
                   const row = results.rows.item(i);
                   // perform API and update query
                   var query = `UPDATE row_details SET offline_status = 'uploaded' WHERE id = ${row.id}`;
                   next.executeSql(query);
               }
          }
      );
      // I want this query to be executed only WHEN all of the above have been completed.
      tx.executeSql(&quot;SELECT * FROM row_details WHERE offline_status = 'uploaded'&quot;);
  });
  </code></pre>
  <p>I want the last SELECT query be performed ONLY when the UPDATE queries have been completed. Currently, what happens is that both the queries run in parallel since tx.executeSql is async.</p>