Is Lookup possible irrespective of matching key?

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
dwscblr
Participant
Posts: 19
Joined: Tue May 18, 2004 12:39 am

Is Lookup possible irrespective of matching key?

Post by dwscblr »

I was just wondering if there is any way where I can have a lookup irrespective of what the hashfile key field is looked up against. In other words can I look up a hash File for a particular field(say to be used in transformer) in all circumstances and have that for manipulation of all the incoming streaming records from other link.

Basically it started like this.I have a simple rule something like 'Cost A/sum of all Costs A*100).In essence,I've to find % contribution of each cost against all. I tried using something like this

FlatFile-->Aggregator------------>HashFile
|Lkup
|
Copyof_FlatFile-->Trans1------->Trans2
|
|
Output File

And I wanted to lookup against the hashFile always where I'm collecting the sum of all CostsA; then I could have used it in Trans2. There is no 'primary key' in the source input file.
I'm stumped! :roll: Any answer for my Q. Or any better idea to do this otherwise simple looking thing in one job. Another way is to break up this into two jobs/b4 subroutine and use the output from there as input for this job.
dwscblr
Participant
Posts: 19
Joined: Tue May 18, 2004 12:39 am

Post by dwscblr »

Sorry,some formatting error. The vertical Lkup bar/output bar is at the end of the diagram...Lkup from HashFile to Trans2 and then final streaming output from Trans2 to Output File.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Simple logic tells you that you need two passes through the data. You can not know (sum of all costs) without one pass through the data. Load these totals into a hashed file keyed by whatever it is you're grouping (categorising) by, then calculate the percentages in a second pass.

Or you could load appropriate columns from the data into a hashed file (or UniVerse table) and use UniVerse SQL to retrieve the percentages.
SELECT CostA, PCT CostA FROM TableName; :D
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
dwscblr
Participant
Posts: 19
Joined: Tue May 18, 2004 12:39 am

Post by dwscblr »

I also tried the same way but the problem was 'key' for the hash file. I found another way. I added a transformer before the aggregator. Then added dummy column in both the transformers,new Trans and Trans1 (in exactly the same way), carried it over to HashFile and made it as the key for the lookup. It was easy thereafter.
Ray,your second suggestion was good too.

Thanks a lot. I wonder how do u find time to reply to all the stupid Qs like this :wink:
Post Reply