tJava - IF ELSE statement fails!

Highlighted
Nine Stars

tJava - IF ELSE statement fails!

I run SQL and pass the result of "STOP or "GO" to tMap and then tContextLoad:

 

tTeradataInput > tMap > tContextLoad

˅

OnSubjobOK

˅

tJava

 

The tJava code is:

System.out.println( "Context variable value is:"+context.myCHECK);

 

globalMap.put("myCHECK", context.myCHECK);
System.out.println( "Global variable value is:"+globalMap.get("myCHECK"));

 

if(globalMap.get("myCHECK")=="STOP"){System.exit(99);}else{ System.out.println("START GOING NOW");}

 

System.out.println("FAILED TO STOP");

 

 

The result is correct when the context variable is GO:

Context variable value is:GO
Global variable value is:GO
START GOING NOW
FAILED TO STOP

 

But when the context variable is STOP the exit command doesn't trigger:
Context variable value is: STOP
Global variable value is: STOP
START GOING NOW
FAILED TO STOP

 

Any ideas how to make the if else statement actually exit the job?


Accepted Solutions
Highlighted
Sixteen Stars
Sixteen Stars

Re: tJava - IF ELSE statement fails!

Hi,

Replace the "if" statement like this:

if(((String)globalMap.get("myCHECK")).equals("STOP")) System.exit(99);
System.out.println("START GOING NOW"); // no else require

 


TRF

View solution in original post


All Replies
Highlighted
Sixteen Stars
Sixteen Stars

Re: tJava - IF ELSE statement fails!

Hi,

Replace the "if" statement like this:

if(((String)globalMap.get("myCHECK")).equals("STOP")) System.exit(99);
System.out.println("START GOING NOW"); // no else require

 


TRF

View solution in original post

Highlighted
Nine Stars

Re: tJava - IF ELSE statement fails!

Thanks!

2019 GARTNER 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

Best Practices for Using Context Variables with Talend – Part 1

Learn how to do cool things with Context Variables

Blog

Migrate Data from one Database to another with one Job using the Dynamic Schema

Find out how to migrate from one database to another using the Dynamic schema

Blog

Best Practices for Using Context Variables with Talend – Part 4

Pick up some tips and tricks with Context Variables

Blog