[resolved] Join on tmap and default value

One Star

[resolved] Join on tmap and default value

Hi,
I've made a join into a tmap.
- table #1: pid, data1
- table #2: pid, cid
I'm doing database INSERT : pid( found into #1) + cid (found into #2).
But data are incomplete. If i don't have a cid, i've to use a default value as cid.
How can i do ?
Thanks for help.

Accepted Solutions
Employee

Re: [resolved] Join on tmap and default value

If your tMap does a Left Join, then the field cid will be null if there is no match. You can convert that null into some other value by using this expression in the output field:
row1.cid == null ? "no cid" : row1.cid
(Instead of row1, use the actual name of the input connection.)
Hope this helps.

All Replies
Employee

Re: [resolved] Join on tmap and default value

If your tMap does a Left Join, then the field cid will be null if there is no match. You can convert that null into some other value by using this expression in the output field:
row1.cid == null ? "no cid" : row1.cid
(Instead of row1, use the actual name of the input connection.)
Hope this helps.
One Star

Re: [resolved] Join on tmap and default value

Hi aspiegel,
I have the same question but a slight change. How to use database default values instead of specifying our own default values?

Thanks.
Community Manager

Re: [resolved] Join on tmap and default value

Hi
Don't add this column on schema when inserting records into table, the default value will be inserted into the column.
Best regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: [resolved] Join on tmap and default value

Thanks alot shong. It works.
One Star

Re: [resolved] Join on tmap and default value

Hi,
I have a different situation now for the same question above. I have to compare input values for null and if it is null then I have to load the default value (specified while creating tables) in that column, otherwise source data. So, the question is - if I don't add the column in the output schema then how can I load the data coming from the source.

Thanks.
Seven Stars

Re: [resolved] Join on tmap and default value

Use a tMap to send the incoming data to two different outputs (one with the column and one without) based on whether the incoming value is null or not.