Regarding Join Condition

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
Diya
Participant
Posts: 38
Joined: Fri Feb 17, 2006 7:02 am

Regarding Join Condition

Post by Diya »

Hi All,

I need to join 2 tables based on one key coloumn.
I need to populate a value for a perticular coloumn based on matched records i.e one type of value for matched records
and different value for unmatched records.



ex:If the records in two tables satisfy the join condition then

for matched records
location

usa

Else,


for unmatched record

location

uk

Could you please help out on this

Thanks in advance,
I_Server_Whale
Premium Member
Premium Member
Posts: 1255
Joined: Wed Feb 02, 2005 11:54 am
Location: United States of America

Post by I_Server_Whale »

Hi Diya,

You can achieve this by loading one of tables into hashed file as a reference table.

Now, use one native DB stage or ODBC stage for one table, a transformer, a hashed file (as said above, which contains data from the other table) and one target stage (can be a seq. or hashed file, depends on your needs).

Check if the key exists (FOUND) in the hashed file. If not then populate your column with UK else populate with US.

Hope that helps.

Thanks,
Naveen.
Anything that won't sell, I don't want to invent. Its sale is proof of utility, and utility is success.
Author: Thomas A. Edison 1847-1931, American Inventor, Entrepreneur, Founder of GE
Diya
Participant
Posts: 38
Joined: Fri Feb 17, 2006 7:02 am

Post by Diya »

Hi Naveen

Thanks a lot for quick response,i am developing in parellel jobs.
hash file is not availble in parelle stages.i suppose.

can you explain me how to achieve in parellel jobs.

regards,
vinaya
elavenil
Premium Member
Premium Member
Posts: 467
Joined: Thu Jan 31, 2002 10:20 pm
Location: Singapore

Post by elavenil »

Do outer (left/right) join of those two tables and check the other table values to identify (un)matching records then populate the column that you want to derive.

HTWH.

Regards
Elavenil
amsh76
Charter Member
Charter Member
Posts: 118
Joined: Wed Mar 10, 2004 10:58 pm

Post by amsh76 »

It depends on your tables..

Out of two tables can we say that one will have all the records for that key ? Or Keys are divided among two tables ?

If its the first case, then you can use Inner Join or Even lookup stage, but if its the second scenario than you will have to do left or Right outer join.

IHTH..
Post Reply