Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>IMO easiest way is to </p> <ul> <li>Add Return value to remote proc.</li> <li>Wrap remote proc into transaction and try catch (inside remote proc). If error happened return false. </li> <li>On local stored proc if false, simply do not continue. </li> </ul> <p>I also fail to understand the reason behind multiple BEGIN TRANS / COMMIT in the local proc. I mean if this is month end rollup, shuldn't this be one big transaction rather than a bunch of small? Otherwise your trans 1 and 2 may commit successfully, but 3 will fail and that's that. </p> <p>Names are made up ofc:</p> <pre><code> CREATE PROC [remote].db.REMOTE_PROC ( @return_value int output ) AS BEGIN SET XACT_ABORT ON; BEGIN TRY BEGIN TRANS ... do stuff ... set @return_value = 1; COMMIT; END TRY BEGIN CATCH set @return_value = 0; END CATCH END </code></pre> <p>and the local proc</p> <pre><code> CREATE PROC [local].db.[monthlyRollUp] AS BEGIN SET XACT_ABORT ON; declare @ret int; EXECUTE [remote].dbo.REMOTE_PROC @return_value = @ret OUTPUT; IF @ret = 0 PRINT 'ERROR :(' RETURN END IF BEGIN TRANS -- one big transaction here EXEC [LOCAL].[DB].[table].[sp1]; EXEC [LOCAL].[DB].[table].[sp2]; EXEC [LOCAL].[DB].[table].[sp3]; EXEC [LOCAL].[DB].[table].[sp4]; COMMIT; END; </code></pre> <p>afair [remote].dbo.REMOTE_PROC runs its own transaction space, and returns 1 if successful. Local proc, checks the return value and decides whether to proceed or not. </p> <p>sp1 sp2 sp3 and sp4 are all running in one single transactions, as having multiple transactions for each of them does not really make much sense to me. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

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