Comparison between two tables

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
kool_cons
Participant
Posts: 68
Joined: Thu Jul 07, 2005 3:41 pm

Comparison between two tables

Post by kool_cons »

Hello All,
We have two tables say A,B with same meta data which has some primary keys and date field. My aim is to insert a row from A if it is not in B into C table. else insert a row from B which is latest row(less than 4 months) based on date into C table.
Could you please guide how to do it in server/parallel jobs.

thanks in advance.
kduke
Charter Member
Charter Member
Posts: 5227
Joined: Thu May 29, 2003 9:47 am
Location: Dallas, TX
Contact:

Post by kduke »

If you are saying the keys are missing then lookup A keys into B table and if not found then insert into C. Have a second job to lookup B keys into A table.

If it is more than keys then you might be able to use MINUS queries if the tables are small and if your database has MINUS.
Mamu Kim
kool_cons
Participant
Posts: 68
Joined: Thu Jul 07, 2005 3:41 pm

Post by kool_cons »

Thats not i was saying about keys.
I need to write programming code in transformer based on requirements which i posted before like comparing rows in two tables with same metadata.
kduke
Charter Member
Charter Member
Posts: 5227
Joined: Thu May 29, 2003 9:47 am
Location: Dallas, TX
Contact:

Post by kduke »

My aim is to insert a row from A if it is not in B into C table.
If a row is not in B then the keys are not there otherwise explain yourself better.
Mamu Kim
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Why not just build the appropriate difference query as SQL and execute that?
Otherwise, perform a reference lookup and constrain the output to be that the lookup failed (perhaps use reflink.NOTFOUND link variable)
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
kool_cons
Participant
Posts: 68
Joined: Thu Jul 07, 2005 3:41 pm

Post by kool_cons »

kduke,

table A and B have a,b,date as fields. a and b are primary keys. Now i need to build a new table say C based on those two tables. C has also same metadata as A and B. Here are the conditions for extracting data to C from A and B.
if the row is in A but not in B then insert into C
if the row is in C and is <4months old insert row into C.
if the row is in A and B then insert into C from A.
I am thinking to create a hash file from A and lookup to B.then insert to C. But i am confusing about logic in transformer. also i need to know how you can manipulate date>4months. based on that i have to have latest dates in C.
thanks a lot.
Post Reply