How to Use Context Variable on Run if Row Component

Highlighted
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
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.
           

2019 GARNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch Now

Best Practices for Using Context Variables with Talend – Part 4

Pick up some tips and tricks with Context Variables

Blog

How Media Organizations Achieved Success with Data Integration

Learn how media organizations have achieved success with Data Integration

Read

Tutorial

Introduction to Talend Open Studio for Data Integration.

Watch