cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

With(updlock) in nested transactions

MCMartin
Participant
3,221

If with(updlock) is used inside a nested transaction will the lock be released at the next or the final commit?

Accepted Solutions (1)

Accepted Solutions (1)

VolkerBarth
Contributor

AFAIK, SQL Anywhere does not really support nested transactions. Even when using BEGIN TRANSACTION/COMMIT TRANSACTION for T-SQL compatibility, this should behave like "nested savepoints". Given that, I would think there is only one real "commit", and until that, the lock will be hold.

Breck has written en detail on that in his great book and has cited it here, too (and I'm free to take a quote from that, too:):

The term "nested transaction" is sometimes used when @@TRANCOUNT rises to 2 or higher. That term is misleading, however, because only the outermost transaction has any meaning as far as database changes and locks are concerned. When @@TRANCOUNT rises to 2 or higher, a COMMIT statement does absolutely nothing except lower the @@TRANCOUNT value. A nested transaction implies that changes made in an inner transaction may be made permanent while changes made in the outer transaction are rolled back, and that simply is not possible in SQL Anywhere; there is no such thing as a nested transaction.

Answers (0)