开发者

What's the case that requires nested transaction?

开发者 https://www.devze.com 2023-04-06 22:54 出处:网络
Even a transaction is nested, it won\'t be updated until outmost transaction commits. So what\'s the meaning of nested transaction and what\'s the specific situation that requires the feature?开发者_运

Even a transaction is nested, it won't be updated until outmost transaction commits. So what's the meaning of nested transaction and what's the specific situation that requires the feature?开发者_运维百科


for example assume such a situation:

Class A
{
 /// props
 save();
}

class B
{
  A a{get;set};
  // other props
  save();
}

now when you want to save B, you first save A assume in saving A you have some service calls for verification or etc, such a situation in saving B (some verifications) so you need rollback if B can not verified, also you should to rollback when you can't verify A so you should have nested one (in fact Separation of concern cause to this, you can mix all things and have a spaghetti code without nested transaction).


There is nothing called Nested Transactions.

The only transaction that SQL considers, is the outermost one. It's the one that's committed or is rolled back. Nested Transactions are syntactically valid, that's all. Suppose you call a procedure from inside a transaction, and that procedure has transactions itself, the syntax allows you to nest transactions, however the only one that has any effect is the outermost.

edit: Reference here : http://www.sqlskills.com/BLOGS/PAUL/post/A-SQL-Server-DBA-myth-a-day-(2630)-nested-transactions-are-real.aspx

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号