home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.databases.ms-sqlserver      Notorious Rube Goldberg contraption      19,505 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 19,258 of 19,505   
   Anton Shepelev to All   
   Re: Using sp_getapplock outside a transa   
   29 Nov 17 15:22:26   
   
   From: anton.txt@g{oogle}mail.com   
      
   Erland Sommarskog to Anton Shepelev:   
      
   >>An  inner  BEGIN TRAN only increments the counter,   
   >>an inner COMMIT TRAN decrements it, but (!)  ROLL-   
   >>BACK TRAN  does actually undo the the outer trans-   
   >>action and sets the counter to zero.  This is  all   
   >>very  unintuitive to me, and requires special han-   
   >>dling of ROLLBACKs in  both  T-SQL  code  and  the   
   >>client application.   
   >   
   >It  becomes  more intuitive if you stop to think in   
   >terms of "outer transaction".  A transaction is all   
   >there is.  So the ROLLBACK will roll back it all.   
   >   
   >The point with BEGIN/COMMIT increase @@trancount is   
   >that it makes it easier  to  nest  procedures  that   
   >both start transactions.   
      
   What  about  error  handling?   In  the case of pure   
   nesting I could simply ensure that every  BEGIN TRAN   
   has  a  corresponding  COMMIT  or ROLLBACK, probably   
   with the help of a TRY..CATCH block.  In the current   
   model,  however, it is a tad less trivial, because I   
   must test @@TRANCOUNT to see whether a  nested  call   
   did  not  roll  back my transaction in the course of   
   its own error handling logic.   
      
   --   
   ()  ascii ribbon campaign - against html e-mail   
   /\  http://preview.tinyurl.com/qcy6mjc [archived]   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca