When should I use SQLTransaction

What time is suitable for using SQLTransaction?

I use them for all my INSERT, UPDATE, and DELETE statements.

Is this the right use or am I going through a bit?

+4
source share
3 answers

Use a transaction if you want a number of operators to be processed atomically - either they all succeed, or are committed, or they are all rolled back.

Since simple operators are already atomic, you do not need to explicitly create a transaction around each individual operator.

+7
source

You need a transaction only if you plan to make several statements and plan to undo all changes to the data that occurred as a result of statements if an error occurred somewhere in the line. Combining separate update / delete instructions is not required. If an error occurs with one command, just understand and handle the error in your interface code.

+2
source

If your teams are only one released, and not a group, then this is probably too large. Transactions are used to group sql commands together, a group that should have all members, or nothing at all.

http://en.wikipedia.org/wiki/Atomicity_%28database_systems%29

+1
source

All Articles