How to return multiple column values with if condition?
Currently I wrote like below and it is giving me error.
The logic is subscriber info is null then return SP_SERV_ID, SITE_A_ID AND SUB_ACCOUNT field values.
row1.SUBSCRIBER == null ? row1.SP_SERV_ID, row1.SITE_A_ID, row2.Sub_Account
Any help is much appreciated.
What exactly are you trying to do? It looks like you are trying to actually apply logic to returning a row based on a column values. This can be done using the filtering in a tMap component. Can you give a bit more information on this. There will be a way of doing this, but we need a bit more info.
Thanks for the response.
Here is what I am trying to achieve.
row1.SUBSCRIBER == null ? row1.SP_SERV_ID ||
row1.SUBSCRIBER == null ? row1.SITE_A_ID ||
row1.SUBSCRIBER == null ? row2.Sub_Account
When I tested this I get below error,
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
If Subscriber is null then return serv_id, site_a_Id, sub_account
What do you want to do?
Do you want to concatenate SP_SERV_ID, SITE_A_ID and Sub_Account?
In this case, try this:
row1.SUBSCRIBER == null ? row1.SP_SERV_ID + row1.SITE_A_ID + row2.Sub_Account : null
Why can you not do this with a tMap using a filter on the output? Take a look here: https://community.talend.com/t5/custom/page/page-id/Condition-based-filters-w-tMap
The condition you have given needs to be thought out differently. You are essentially concatenating the logic for 3 columns in one condition. If you want this to apply to each of the columns independently, you will need to break down the condition into 3 conditions (one per column). I *think* filtering a tMap output will better suit your requirement though.