One Star

How to Use Context Variable on Run if Row Component

Hi..
I have handle SQL Server  error in stored procedure using TRY and CATCH Block.Stored Procedure gives the Error output as
ErrorMessage ,ErrorSeverity and ErrorState.All these values are stored in context variables.
On RunIf Trigger i want check condition as mentioned belowed:-
If ErrorState has no value then it should execute next sub job of extracting data from table into CSV file.
And ErrorState has value then it should not execute next sub job.
Thanks in Advance for help
Regards
Amruta Joshi
2 REPLIES
Five Stars

Re: How to Use Context Variable on Run if Row Component

Assuming that, by "no value" you mean null :-
Your two If tests are simply :-
context.ErrorState == null
context.ErrorState != null
One Star

Re: How to Use Context Variable on Run if Row Component

Hi..
CASE 1:-
Snippet Code:- 
BEGIN CATCH
    DECLARE @ErrorMessage NVARCHAR(4000) = ERROR_MESSAGE();
    DECLARE @ErrorSeverity INT = ERROR_SEVERITY();
    DECLARE @ErrorState INT = ERROR_STATE();
  END CATCH
     --Retrieves the error message along with RowId and BatchTransId where error occured
    SELECT @ErrorMessage As ErrorMessage,@ErrorSeverity As ErrorSeverity,@ErrorState  As ErrorState 
Then i get ErrorMessage with value as null and set in context Variable and Checks Context.ErrorMessage==null in RunIf Trigger It works fine.
But In CASE2 :-
BEGIN CATCH
    DECLARE @ErrorMessage NVARCHAR(4000) = ERROR_MESSAGE();
    DECLARE @ErrorSeverity INT = ERROR_SEVERITY();
    DECLARE @ErrorState INT = ERROR_STATE();
  SELECT @ErrorMessage As ErrorMessage,@ErrorSeverity As ErrorSeverity,@ErrorState  As ErrorState
  END CATCH
In this Case Select statement will executed if error occurs ,but no errors occurs errorMessage will have no value.
Since Context variables are in tjava_row component
How to check the whether Context .ErrorMessage has value or not?
Thanks for ur help in advance.