If/Then in tMap with Long Value

Four Stars

If/Then in tMap with Long Value

I've got a long value coming over in a tFileDelimitedInput lookup defined as a long. I want to forward a null value to the output if the value is null. Currently the value defaults to 0 if the lookup doesn't exist.
I know I can use this expression for a string...
stringvalue == "value" ? "true_value" : "false_value"
But I'm getting an error on the long value. I tried...
longvalue == null ? null : longvalue
Thanks.
Community Manager

Re: If/Then in tMap with Long Value

Helllo
But I'm getting an error on the long value. I tried...

if you uncheck the 'nullable' option on schema, this column is not object type, so you can't the following expression:
row1.colName==null?null:value1
What you could do is:
a)Check the 'nullable' option and use expression: row1.colName==null?null:value1.
b)Using the folllowing expression:
row1.colName==0?setAFixedValueReplace0:row1.colName

Best regards
shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
Four Stars

Re: If/Then in tMap with Long Value

I guess the value coming over is "0" due to the condition you described on the input I had. Thanks for the assistance.
One Star

Re: If/Then in tMap with Long Value

I'm trying to do something similar:
I am reading an int value in tFileInputXML.
If the XML field is not there, the value is null and I want tmap to pass the null value to the output (xls).
If it is not null, then I want to divide by 10 and output the results as a double.
Relational.ISNULL(row1.colName)?nullSmiley Sad(double)(row1.colName) / 10)
If I check the "Nullable" in the tFileInputXML, then I get a null pointer exception?
Same problem if I use row1.colName==null?nullSmiley Sad(double)(row1.colName) / 10)