if block in talend

0 votes
hi , i am new to talend , can anyone tell me how to properly use "if" blocks  in talend ?? i see  that we can use the if bloc kin a lot of spots but i cannot figure out where , all i know until now , is that "if" block is possible when linking 2 components , also in a map in filter section  and also in some java components ; but where else can we invoke the "if" can we do it between sub jobs and in other spots ?
Dec 8, 2020 in Talend by aminegac
• 570 points
2,823 views

2 answers to this question.

+1 vote

Hi, @Aminegac,

If/else statement

In the Expression Builder, the if / else statement can be written as follows:

condition?value if true:value if false

You can perform a null test before calling a Java method; otherwise, it will throw a null pointer exception if the input data contains a null value. For example:

row1.Postal_code==null?null:row1.Postal_code.toUpperCase()


Hope this helps.

To learn more about Talend' it's recommended to join Talend training today.

Thanks.

answered Dec 8, 2020 by anonymous
• 65,770 points
okay , thank you :)
+1 vote

@Aminegac,

In the Basic settings view of a Run if connection, you can set the condition to the subJob in Java.

You can use variables in your condition. Pressing Ctrl+Space allows you to access all global and context variables. 

Procedure

  1. Create a Job and drop three components to the design workspace: a tFileInputDelimited, a tLogRow, and a tMsgBox.
  2. Connect the components as follows:
    • Right-click the tFileInputDelimited component, select Row > Main from the contextual menu, and click the tLogRow component.

    • Right-click the tFileInputDelimited component, select Trigger > Run if from the contextual menu, and click the tMsgBox component.

  3. Configure the tFileInputDelimited component so that it reads a file that contains no data rows.
  4. Select the Run if connection between the tFileInputDelimited component and the tMsgBox component, and click the Component view. In the Condition field on the Basic settings tab, pressing Ctrl+Space to access the variable list, and select the NB_LINE variable of the tFileInputDelimited component. Edit the condition as follows:
    ((Integer)globalMap.get("tFileInputDelimited_1_NB_LINE"))==0
  5. Go to the Component view of the tMsgBox component, and enter a message, "No data is read from the file" for example, in the Message field.
  6. Save and run the Job. You should see the message you defined in the tMsgBox component.
answered Dec 8, 2020 by Nikita
thank you @Nikita

Related Questions In Talend

0 votes
1 answer
0 votes
2 answers
0 votes
1 answer

Converting Columns into Rows in Talend

Hi, You can try using tNormalize component along ...READ MORE

answered Apr 11, 2018 in Talend by code.reaper12
• 3,500 points

edited Apr 11, 2018 by code.reaper12 6,494 views
0 votes
1 answer

tWaitForFile component insufficiency in Talend

Regarding your first issue, tWaitForFile component provides ...READ MORE

answered Apr 11, 2018 in Talend by geek.erkami
• 2,680 points
2,479 views
0 votes
1 answer

Looping through all the schemas in Talend

It is really simple to make tOracleInput ...READ MORE

answered Apr 11, 2018 in Talend by code.reaper12
• 3,500 points
1,876 views
0 votes
1 answer

Parsing JSON in Talend

While working with JSON files, one thing ...READ MORE

answered Apr 3, 2018 in Talend by code.reaper12
• 3,500 points
4,064 views
+1 vote
1 answer
0 votes
2 answers

Read Data from Rest API's through Talend and store it in Oracle

Hi, @Abhishek, Regarding your query, I would suggest ...READ MORE

answered Oct 15, 2020 in Talend by Gitika
• 65,770 points
3,105 views
0 votes
1 answer

How to loading flat file from configuration in Talend?

Hey, @There, Regarding your query you need to ...READ MORE

answered Jun 4, 2020 in Talend by Gitika
• 65,770 points
2,152 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP