display message in console when no rows in output file

One Star

display message in console when no rows in output file

Hello,
I would wand to know how I can control the number of rows of a file. When there is no row it displays in the console "There is no row" and if there are rows I want to display "there is (number of rows)rows"
regards,
JOLLYJOHN
One Star

Re: display message in console when no rows in output file

Hello,

well in the place of the tLogRow we can use a tJava to display the value of global variable from components with the commande System.out.println();

for example like this code :

System.out.println(((Integer)globalMap.get("tRowGenerator_1_NB_LINE")));

Best Regards

Jeremie
One Star

Re: display message in console when no rows in output file

you can use a tJava component, and connect it to your database component via a "On Subjob Ok" link
in tJava you could use something like this:
if(((Integer)globalMap.get("tFileOutputExcel_1_NB_LINE")).equals(0)) {
System.out.println("There are no rows.");
}
else {
System.out.println("There are " + ((Integer)globalMap.get("tFileOutputExcel_1_NB_LINE")) + " rows.");
}

or, to make it grammatically correct, and easier to read:
System.out.println("");
if( ((Integer)globalMap.get("tFileOutputExcel_1_NB_LINE")).equals(0) ) {
System.out.println("There are 0 rows.");
}
else if( ((Integer)globalMap.get("tFileOutputExcel_1_NB_LINE")).equals(1) ) {
System.out.println("There is " + ((Integer)globalMap.get("tFileOutputExcel_1_NB_LINE")) + "row.");
}
else {
System.out.println("There are " + ((Integer)globalMap.get("tFileOutputExcel_1_NB_LINE")) + " rows.");
}
System.out.println("");
One Star

Re: display message in console when no rows in output file

or you could use If links, like in the first attached picture
Note: the "System.out.println("***tJava_#***");" lines were just to show you which tJava_# the summary line printed from, and wouldn't be necessary in your solution
If (order:1)
((Integer)globalMap.get("tFileInputDelimited_1_NB_LINE")).equals(0)

tJava_1
System.out.println("");
System.out.println("***tJava_1***");
System.out.println("There are no rows.");
System.out.println("");

If (order:2)
((Integer)globalMap.get("tFileInputDelimited_1_NB_LINE")).equals(1)

tJava_2
System.out.println("");
System.out.println("***tJava_2***");
System.out.println("There is " + ((Integer)globalMap.get("tFileInputDelimited_1_NB_LINE")) + "row.");
System.out.println("");

If (order:3)
((Integer)globalMap.get("tFileInputDelimited_1_NB_LINE")) > 1

tJava_3
System.out.println("");
System.out.println("***tJava_3***");
System.out.println("There are " + ((Integer)globalMap.get("tFileInputDelimited_1_NB_LINE")) + " rows.");
System.out.println("");

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