Range Lookup

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
yinyin61
Participant
Posts: 28
Joined: Mon Nov 07, 2005 7:40 pm

Range Lookup

Post by yinyin61 »

hi,

i'm facing problem of doing range lookup for hash file. below is my source and lookup data

Source
ID Rng
1 156

Lookup Data
ID Rng1 Rng2
1 100 150
1 151 200
2 100 200

I need to lookup the ID and the Rng should be between Rng1 and Rng2.

Both the Source and Lookup data are .csv file. I had loaded Lookup Data into hash file with ID as key but then i realize that the record will be overwrite by the next record and results only ID 1, Rng1 151, Rng2 200 in the hash file.

So anyone can give me suggestion what can i solve this problem? Thanks in advance... :oops:
Thank you.

Regards,
Aileen Chong
Software Engineer
Edwink
Participant
Posts: 47
Joined: Sat Aug 19, 2006 4:57 am
Location: Chennai

Post by Edwink »

hope merge stage can slove this issue
yinyin61
Participant
Posts: 28
Joined: Mon Nov 07, 2005 7:40 pm

Post by yinyin61 »

Edwink wrote:hope merge stage can slove this issue
thanks for the reply :)

i guess i know how to do already.. :P
Thank you.

Regards,
Aileen Chong
Software Engineer
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post by kumar_s »

Yes, there could be several method to solve this. Do you mind sharing the method you have chosen. So that it can be useful for further searchers, somtimes you may bet better advise as well.
And you can mark the topic as resolved as well.
Impossible doesn't mean 'it is not possible' actually means... 'NOBODY HAS DONE IT SO FAR'
yinyin61
Participant
Posts: 28
Joined: Mon Nov 07, 2005 7:40 pm

Post by yinyin61 »

kumar_s wrote:Yes, there could be several method to solve this. Do you mind sharing the method you have chosen. So that it can be useful for further searchers, somtimes you may bet better advise as well.
And you can mark the topic as resolved as well.
of course i don't mind sharing my method :wink:

i use merge stage to merge Source and Lookup Data (key is Source.ID = LookupData.ID) then i use a transformer stage to do the range lookup. I add a stage variable in transfomer with the below derivation:

If Source.Rng >= LookupData.Rng1 And Source.Rng <= LookupData.Rng2 Then @TRUE Else @FALSE

This above stage variable will act as a constraint.

Welcome any better idea to solve this :roll:
Thank you.

Regards,
Aileen Chong
Software Engineer
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

The stage variable could have been more simply derived as

Code: Select all

 Source.Rng >= LookupData.Rng1 And Source.Rng <= LookupData.Rng2 
If expression Then @TRUE Else @FALSE is redundant because expression itself must return a true/false result. In DataStage BASIC, 0 or "" (or anything that is equivalent) is regarded as False, and any other non-null value is regarded as True.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
yinyin61
Participant
Posts: 28
Joined: Mon Nov 07, 2005 7:40 pm

Post by yinyin61 »

ray.wurlod wrote:The stage variable could have been more simply derived as

Code: Select all

 Source.Rng >= LookupData.Rng1 And Source.Rng <= LookupData.Rng2 
If expression Then @TRUE Else @FALSE is redundant becau ...
mm... i dont have the premium membership so not able to read your reply :(
Thank you.

Regards,
Aileen Chong
Software Engineer
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post by kumar_s »

But its easy to get the membership. By that you can help Dsxchange to help you.
Impossible doesn't mean 'it is not possible' actually means... 'NOBODY HAS DONE IT SO FAR'
yinyin61
Participant
Posts: 28
Joined: Mon Nov 07, 2005 7:40 pm

Post by yinyin61 »

kumar_s wrote:But its easy to get the membership. By that you can help Dsxchange to help you. ...
need to pay USD99 a yr in order to get the membership...
Thank you.

Regards,
Aileen Chong
Software Engineer
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post by kumar_s »

May be less than 3cents a day. Sometimes you may find it more helpful for your professional life to get a quick solution.
Impossible doesn't mean 'it is not possible' actually means... 'NOBODY HAS DONE IT SO FAR'
yinyin61
Participant
Posts: 28
Joined: Mon Nov 07, 2005 7:40 pm

Post by yinyin61 »

kumar_s wrote:May be less than 3cents a day. Sometimes you may find it more helpful for your professional life to get a quick solution. ...
i'll think about it, thanks :)
Thank you.

Regards,
Aileen Chong
Software Engineer
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Corporate discounts are available. There's a link from the DSXchange home page to information about these. Premium membership money is entirely consumed helping to pay for the bandwidth costs of DSXchange.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
yinyin61
Participant
Posts: 28
Joined: Mon Nov 07, 2005 7:40 pm

Post by yinyin61 »

ray.wurlod wrote:Corporate discounts are available. There's a link from the DSXchange home page to information about these. Premium membership money is entirely consumed helping to pay for the bandwidth costs of DSXchange.
yup, i will ask my company whether can register the premium membership for me or not :)
Thank you.

Regards,
Aileen Chong
Software Engineer
Post Reply