Talend Connect
Virtual Summit
JOIN US!
And visit the Customer
& Community Lounge.
May 27-28, wherever you are.

tFileRowCount, read "0 rows" without "null pointer exception"

Highlighted
Two Stars

tFileRowCount, read "0 rows" without "null pointer exception"

Hi, the job works as follows:

I need to recover data from the WS, so if the WS returns 0 data (0 rows), I need to throw an exception, not the "NullPointerException". I tried with the "tFileRowCount" to read the rows, if rows == 0 throw exception otherwise "tfileOutputDelimited", and it did not work. I made screenshots to make it clear at the job level: someone can help me plzz!Screenshot from 2018-10-16 11-40-30.png

 

Screenshot from 2018-10-16 11-52-24.png

 

 

 


Accepted Solutions
Highlighted
Two Stars

Re: tFileRowCount, read "0 rows" without "null pointer exception"

Thank you for your answer, I will test it later.

Beside that, I found the solution that meets my needs;
we do a test with the "if":  

((Integer) globalMap.get (" tLogRow_1_NB_LINE ")) == 0

If the WS returns 0 data, we generate empty files but with a warning message "WARNING :: This WebService is down and returns No Data" with the tDie.
I hope it will help you one day Smiley Happy

Screenshot from 2018-10-16 14-49-37.pngScreenshot from 2018-10-16 14-53-44.png

View solution in original post


All Replies
Highlighted
Employee

Re: tFileRowCount, read "0 rows" without "null pointer exception"

Hi,

 

     Could you please try the below method? Here, when I am specifying zero records in trowgenerator, no records will be written into the target file. I have allowed the subjob to complete. I verified the number of records loaded by the pseudo variable NB_LINE linked to tfileoutputdelimited (use control space to view it) and add it as condition in Run if line 

 

((Integer)globalMap.get("tFileOutputDelimited_1_NB_LINE")) ==0

 

This resulted in printing the value in second tjava job. The concept remains same for your job also.

 

If the answer has helped you, could you please mark the topic as resolved? Kudos are also welcome :-)

 

image.png

 

 

 

Warm Regards,

 

Nikhil Thampi

Highlighted
Two Stars

Re: tFileRowCount, read "0 rows" without "null pointer exception"

Thank you for your answer, I will test it later.

Beside that, I found the solution that meets my needs;
we do a test with the "if":  

((Integer) globalMap.get (" tLogRow_1_NB_LINE ")) == 0

If the WS returns 0 data, we generate empty files but with a warning message "WARNING :: This WebService is down and returns No Data" with the tDie.
I hope it will help you one day Smiley Happy

Screenshot from 2018-10-16 14-49-37.pngScreenshot from 2018-10-16 14-53-44.png

View solution in original post

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 2

Part 2 of a series on Context Variables

Blog

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