HTML5 Database Transactions
- by jiewmeng
i am wondering abt the example W3C Offline Web Apps the example
function renderNotes() {
  db.transaction(function(tx) {
    tx.executeSql('CREATE TABLE IF NOT EXISTS Notes(title TEXT, body TEXT)', 
      []);
    tx.executeSql(‘SELECT * FROM Notes’, [], function(tx, rs) {
      for(var i = 0; i < rs.rows.length; i++) {
        renderNote(rs.rows[i]);
      }
    });
  });
}
has the create table before the 'main' executeSql(). will it be better if i do something like
$(function() {
    // create table 1st
    db.transaction(function(tx) {
        tx.executeSql('CREATE TABLE IF NOT EXISTS Notes(title TEXT, body TEXT)', 
          []);
    });
    // when i execute say to select/modify data, i just do the actual action
    db.transaction(function(tx) {
        tx.executeSql(‘SELECT * FROM Notes’, [], function(tx, rs) {
            ...
        }
    });
    db.transaction(function(tx) {
        tx.executeSql(‘INSERT ...’, [], function(tx, rs) {
            ...
        }
    });
})
i was thinking i don't need to keep repeating the CREATE IF NOT EXISTS right?