Lookup without primary keys..Need Help

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
appcon
Participant
Posts: 23
Joined: Wed Jul 07, 2004 8:11 am

Lookup without primary keys..Need Help

Post by appcon »

I have a scenario where I need to lookup a table which has 3 columns
called Begin_Range,End_Range and Acct_Name.

The base table has a column Account. I need to lookup the Xref table and
based on the range it belongs,extract the corresponding Acct_Name.

The lookup has no primary key.

Can anyone suggest a way to do this kind of lookup. The base table is a sequential file and lookup table is an oracle table.

Thanks,
Sri.
roy
Participant
Posts: 2598
Joined: Wed Jul 30, 2003 2:05 am
Location: Israel

Post by roy »

Hi,
depending on the volume of data in question, one way is to load into a table your values and then use a select with a join between the 2 tables to form a hash file with the values you have and the relevant data you need from your lookup table.
i.e. load values to a table a, assuming your lookup table is named b.
perform a "select a.value,b.Acct_name from a,b where a.value >= b.Begin_Range and a.value <= b.End_Range" into a hash file and simply perform an exact match between the values in your input stream to the values in your newly generated hash file.

IHTH,
Roy R.
Time is money but when you don't have money time is all you can afford.

Search before posting:)

Join the DataStagers team effort at:
http://www.worldcommunitygrid.org
Image
KeithM
Participant
Posts: 61
Joined: Thu Apr 22, 2004 11:34 am
Contact:

Post by KeithM »

If I understand your problem correctly you want to get the account name where the account number falls between your range begin and range end.

To do this when you setup your ODBC stage, on the columns tab identify the range begin and range end as keys. Then on the general tab change the query type to user defined. Go to the generated SQL and change the equal joins in the where clause to do greater than/less than on the ranges. Now in the transformer link the account to both ranges and this should give you the results that your looking for. I have not used the Oracle stage but I would think it would be similar.
appcon
Participant
Posts: 23
Joined: Wed Jul 07, 2004 8:11 am

Post by appcon »

Hi Roy and Keith,

The solution worked like a charm. Thank you. You made the solution look so simple.

Thanks once again ....I appreciate your help.

Sri.
Post Reply