Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Talend (if, else) in tJavaRow module

I’m trying to add informations in one column by using tJavaRow module and using conditional expression. The target here is simple. If "Fonction_libelle" column containt "DIRECTEUR" information, add in "Directeur_Oui_Non" column "Oui" else add "Non". I tried this :

if (input_row.Fonction_libelle == "DIRECTEUR") { output_row.Directeur_Oui_Non = "Oui";} else {output_row.Directeur_Oui_Non = "Non";}

The output of this is i’ve got "Non" everywhere but there are some "DIRECTEUR" in "Fonction_libelle" column. Of course there is something wrong but i’m not able to see what…

enter image description here

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Any help would be very appreciated !

>Solution :

Try with .equals() instead of ==

if ("DIRECTEUR".equals(input_row.Fonction_libelle)) {
 output_row.Directeur_Oui_Non = "Oui";}
 else {output_row.Directeur_Oui_Non = "Non";}

"==" is not recommended to compare strings

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading