How can everyone decide that you ought to be wrapping the sql inside a transaction?

Please throw some light about this.

Cheers !!

A transaction ought to be used when you really need some changes must be processed completely to think about the operation complete and valid. Quite simply, if perhaps a percentage executes effectively, will that lead to incomplete or invalid data being saved inside your database?

For instance, for those who have an place then an update, what goes on when the place works and also the update fails? In the event that would lead to incomplete data (within this situation, an orphaned record), you need to wrap the 2 claims inside a transaction to encourage them to complete like a "set".

in case your have greater than a single data modifying statement to complete to accomplish an activity, all ought to be inside a transaction.

By doing this, if the first is effective, but the following ones comes with an error, you are able to rollback (undo) everything as though nothing was ever done.

If you're performing several claims that you simply be prepared to be functionally atomic, you need to wrap these questions transaction.

Whenever you do not need it if area of the operation can complete and some of it does not.