views:

25

answers:

3

Hi,

I have a method

void SaveApplicationData()
{
   begin transaction
   update
   insert
   commit transaction
}

if two users call this method at same time, can these two database transaction run at same time?

thanks!

+1  A: 

yes they can run at the same time

mkoryak
+1  A: 

Large numbers of transactions can be running simultaneously. However, if they're updating the same rows, they may well have locking problems, and one or more may be rolled back. (It's a long time since I dealt with conflicting transactions.)

David Thornley
In Oracle, one transaction would simply wait for the other to finish. The only case where it would be auto rolled back would be if a deadlock occurs.
Jeffrey Kemp
thanks! can or can not, I am still confused.
Ding
@Ding: Transactions can be simultaneous. They will run simultaneously as long as they don't try to change the same data, or in some circumstances if one transaction is reading data another transaction (not yet committed) has changed. Transactions act as if they run in sequence, and Oracle devotes a lot of work to making that run smoothly, but you can start many transactions while one is still processing.
David Thornley
A: 

Make sure of using the proper Isolation Level

Loop