Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>First, why do you emphasis that <code>transaction</code> is atomic? <code>Transaction</code> implies smth that is always atomic, any transaction gurantees that either <strong>all</strong> of it blocks are commited or <strong>not a single</strong> block is commited.</p> <p>Considering the usage of transaction in your case - it depends on your domain logic. Choice is rather simple : </p> <ul> <li>If it's posssible to run only first sp without second - don't use single transaction.</li> <li>If it's not possible - use it.</li> </ul> <p>So if you'd provide further explanations of your domain rules and logic, we can say what scenario suites you best.</p> <p><strong>UPD</strong> Ok, after you've explained it a bit, I see no problem - for sure you can implement it that particular way and get the expected behaviour, so that commands from your both sp would be handed by single transaction and act as one. I would like also to point out possible improvement of the code.</p> <ol> <li><p>You can make exception handling more specific. Right now you are rolling back when anything goes wrong. For example - if <code>Dts.Connections["serverName"];</code> is <code>null</code>, you'd get NullReferenceException before <code>sqlTrans</code> is initialized, and then in <code>catch</code> block you'd get another <code>NullReferenceException</code>,dealing with <code>sqlTrans</code>, which is null</p></li> <li><p>You can split your code into database specific and everything else, just to make sure that your Exception in that block is always exception from database layer. I mean do stuff like</p> <p><code>string temp = retrievedMessage.Substring(203, 17);</code></p> <p><code>int newNumber = (int)(long.Parse(temp) / 777);</code></p></li> </ol> <p>somewhere else, because it's potentially dangerous and can throw an exception. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload