Avisek Chakraborty
Avisek Chakraborty

Reputation: 8309

HTML5 webSQL why SELECT query within a transaction?

In HTML5 webSQL am running SELECT query within a transaction object.

Why do i need to wrap it in a transaction?

is there any alternative way to run it without transaction?

db.transaction(function(tx) { 
  tx.executeSql('SELECT id FROM username', [], function(tx, rs){
    ...
    ...

  });
});

Upvotes: 1

Views: 1058

Answers (1)

Paul Sweatte
Paul Sweatte

Reputation: 24637

The web-sql processing model requires the transaction statement. A transaction instructs the database to treat multiple operations as a unit. Changes to data requested by the queries are not committed until all actions within the transaction block have executed successfully. UPDATE/SELECT race conditions are prevented by locking the database during transactions.

Upvotes: 3

Related Questions