Runif condition

Highlighted
One Star

Runif condition

Hi,
I need to check the condition after tmap, but the run if connector doesnot exist in tmap.I have tried this using tjavarow component also but i am not able to connect my output aafter checking a condition.
Please refer the details below,
--toracleinput -- tmap ----------- toracleoutput 1
------------toracle output 2
In the above job I have to check a if condition like (if context.value = 1) {proceed with toracleoutput1}
(else){proceed with toracleoutput2}
Please advice on the job sequence flow and the ways to check the condition and return output based on the condition.
Thanks and Regards,
mani.

Accepted Solutions
Seven Stars

Re: Runif condition

You cannot apply a condition directly to a flow. You can either:
1. depending on the difference between your tOracleOutputs, apply the condition directly in the tOracleOutput component's parameters e.g. for Table, have the expression: context.value==1?"TableName1":"TableName2"
2. have two output flows from tMap with your condition as an expression filter on the output tables in tMap
3. link the output flow from tMap to a tHashOutput or tFileDelimitedOutput and then have two RunIfs with your condition from your output component to a corresponding input component and then a flow on to your tOracleOutput e.g.
tMap --flow--> tHashOutput --RunIf(context.value==1)--> tHashInput --flow--> tOracleOutput1
--RunIf(context.value!=1)--> tHashInput --flow--> tOracleOutput2

All Replies
Seven Stars

Re: Runif condition

You cannot apply a condition directly to a flow. You can either:
1. depending on the difference between your tOracleOutputs, apply the condition directly in the tOracleOutput component's parameters e.g. for Table, have the expression: context.value==1?"TableName1":"TableName2"
2. have two output flows from tMap with your condition as an expression filter on the output tables in tMap
3. link the output flow from tMap to a tHashOutput or tFileDelimitedOutput and then have two RunIfs with your condition from your output component to a corresponding input component and then a flow on to your tOracleOutput e.g.
tMap --flow--> tHashOutput --RunIf(context.value==1)--> tHashInput --flow--> tOracleOutput1
--RunIf(context.value!=1)--> tHashInput --flow--> tOracleOutput2
One Star

Re: Runif condition

Thanks alot for the help.
One Star

Re: Runif condition

Hi,
I want to send email if my tOracleOutput loads data into database, so I connected it with tSendMail(RunIf), but i'm stuck with the code java.
Can you help please ?
One Star

Re: Runif condition

Sure, at the left of talend window when you re in your job, you have outline tab, you select the tOracleOutput that interest you.
After that you drag and drop the value that interest you NB_LINE_INSERTED for exemple and compare to see if it's positive. It should looks like something like :
((Integer)globalMap.get("tOracleOutput_1_NB_LINE_INSERTED"))>0 || ((Integer)globalMap.get("tOracleOutput_1_NB_LINE_Updated"))>0
the || means or.
good luck
Two Stars

Re: Runif condition

Hi this is not working for me, the tHashInput cant recognize my Oracle DB and cant have a schema.

 
Community Manager

Re: Runif condition

@JaymeNeto, tHashInput is used to read data from memory. On the basic setting panel, select a tHashOutput component if there are several tHashOutput in the same job, and you need to define the same schema as the selected tHashOutput's schema.
----------------------------------------------------------
Talend | Data Agility for Modern Business

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