Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I am trying to write a condition in my tMap translation. It is giving me an error when trying to run. Essentially, I have a required field I am trying to populate on the Output. From the input, I first want to check one of the columns for null. If it is null, I want to use a different column to populate output. Here is what I have written, not sure what I am missing:
row1.Field1 = null ? row1.Field2 : row1.Field1
@ksingh @nthampi @uganesh Thank you all for your help!
I made a few adjustments and got it to work. Here is the final expression I used:
row1.NAME != null && row1.NAME.trim().length() != 0 ? row1.NAME : row1.NUM
I really appreciate all of your input. I'm new to Talend and this is helpful. This board is great. I will be now be a longtime user.
Also, I have tried comparing using = and ==. Either way, I am getting an error when the first field is blank and it is not populating it the 2nd field.
(row1.Field1 == null || row1.Field1.trim().length() == 0 )? row1.Field2 : row1.Field1
Thank you @uganesh. It is now giving me a different error. It is saying:
Token<END-OF-STATEMENT> was not valid. Valid tokens: ? : <FLOAT> <BIGINT> <DECIMAL>
It is all string fields. The input fields are stings and the output field is a string.
I appreciate your help!
(row1.Field1 == null || StringHandling.LEN(row1.Field1)== 0 )? row1.Field2 : row1.Field1
Error looks unrelated.Can you please verify and confirm that , this error comes only with above expression.
Are you using any database Query before. usually these errors are databse related.
can you please give your job screenshots.
Hi,
Seems you are trying to load the String value to a database like DB2 where the data is in different format.
Could you please share the screen shot of the job flow and the component where it is erroring out? There could be some data type mismatch but getting the full error and screen shot of the job only can help us to dig further.
Warm Regards,
Nikhil Thampi
Please appreciate our Talend community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂
They are both actually strings. I am trying to move a string to a string. I have definitely narrowed it down to this translation, because if I just put in default text in that field to test it, it runs the job with no errors. I have confirmed, both fields in the input and the output are strings. Strange behavior.