Compare String using tMap

Ahmed BEN MANSOUR picture Ahmed BEN MANSOUR · Nov 17, 2016 · Viewed 7.7k times · Source

I am using Talend to prepare dataware. I want to compare the string with the contents of a column using the tMap component and create a variable to store in the DB. The problem is that the == operator does not give the right result (Example: row2.recipient == "text"?"text":"" I always get "") and if I use .equals I get errors when executing.

Answer

Corentin picture Corentin · Nov 17, 2016

You will get error if row2.recipient is null, and "==" should not be used when comparing strings. Correct syntax would be :

"text".equals(row2.recipient)?"text":""

Then you will prevent NullPointerExceptions.