Transaction IsolationLevel

Posts   
 
    
Asimov
User
Posts: 113
Joined: 05-Dec-2003
# Posted on: 01-Dec-2004 15:44:11   

Hi,

Maybe someone can help me. If I want to make a read and an update in a table but that I want no one to be able to read the same table while I'm reading/updating, what kind of IsolationLevel should I use? I've read the definition of each type, but even now I'm not sure which one I should use. Thank you simple_smile

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 01-Dec-2004 16:37:47   

Same table or same records?

IsolationLevel.Serializable is the one you're looking for.

Frans Bouma | Lead developer LLBLGen Pro
Asimov
User
Posts: 113
Joined: 05-Dec-2003
# Posted on: 01-Dec-2004 16:41:53   

same record. because for certain entities, when I create a new one, I need to show in advance the "futur" id the user. So in my database I keep track of several table counters instead of using identity. but in the tests two people managed to get the same id (in a transaction, I read the next id, then increment it for the next person). So obviously my transaction prevented simultaneous increment part, but not the read part simple_smile

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 01-Dec-2004 16:49:58   

A serializable transaction will place an exclusive lock on the row. So no-one can read it/access it except when the query specifies teh NOLOCK hint, which is never done in LLBLGen Pro code.

Frans Bouma | Lead developer LLBLGen Pro
Asimov
User
Posts: 113
Joined: 05-Dec-2003
# Posted on: 01-Dec-2004 16:58:05   

great thanks simple_smile