Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik GA: Multivariate Time Series in Qlik Predict: Get Details
cancel
Showing results for 
Search instead for 
Did you mean: 
_AnonymousUser
Specialist III
Specialist III

passing null value to integer column

Hello All,
I need help on how to pass a null value to an integer column.
i have an IF-THEN-ELSE statement to pass value to the integer column like following, but it keeps prompt me error
row4.status=="LIQ"?0 Smiley Sadrow4.status=="CUR"?1 Smiley Sadrow4.status=="MAT"?2:null))
the output column i've set it nullable.
Please help!
Labels (2)
8 Replies
Anonymous
Not applicable

Hi
First, the data type of status column is String.
You'd better use equals() method.
For example, row4.status.equals("LIQ").
Besides, the expression you use will cause NullPointerException.

Regards,
Pedro
Anonymous
Not applicable

Hi Pedro,
Thanks for prompt reply!
Im new to Talend, can you please help to interpret my syntax with tJavaRow which will be applicable in the Expression Builder?
Much Appreciated!
Thanks
Anonymous
Not applicable

Hi
You might code as follow on tJavaRow.
if(input_row.status.equals("MAT"))
output_row.newColumn = 2;
else if(input_row.status.equals("CUR"))
output_row.newColumn = 1;
else if(input_row.status.equals("LIQ"))
output_row.newColumn = 0;
else
output_row.newColumn = null;

Regards,
Pedro
Anonymous
Not applicable

Hi Pedro,
I've add in the component tJavaRow to my flow but the subsequent column from my row1 is not bringing to my last output.
how do i get the value from my first table?
Anonymous
Not applicable

Hi
That's because you forget to add some code.
output_row.ColmunNam = input_row.ColumnName;
Regards,
Pedro
_AnonymousUser
Specialist III
Specialist III
Author

Oh! Now i got it!
Thank You so Much!
Anonymous
Not applicable

Hi,
Just to add to this:
When using the equals method I'd prefer to change the code a little to be like this:
if("MAT".equals(input_row.status))
output_row.newColumn = 2;
else if("CUR".equals(input_row.status))
output_row.newColumn = 1;
else if("LIQ".equals(input_row.status))
output_row.newColumn = 0;
else
output_row.newColumn = null;

This way you can never get a NPE because input_row is empty or input_row.status is null and thus is not a String object (which obviously doesn't have an equals method)
Hope this helps!
Best regards,
Arno
Anonymous
Not applicable

Hi,
This seems like a code lookup that can be done with a spreadsheet and a tMap. The benefit of using the spreadsheet (or delimited file) is that it's easier to view and manage the data. For example, if you export the job, you won't be able to see the MAT/2, CUR/1, LIQ/0 mappings.
If the logic or comparisons are more sophisticated and you have a lot of codes to map, take a look at this post.
http://bekwam.blogspot.com/2011/03/regex-lookup-table-with-talend-open.html