Page 1 of 1

Range Lookup

Posted: Wed Feb 28, 2007 1:58 am
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:

Posted: Wed Feb 28, 2007 2:52 am
by Edwink
hope merge stage can slove this issue

Posted: Wed Feb 28, 2007 3:32 am
by yinyin61
Edwink wrote:hope merge stage can slove this issue
thanks for the reply :)

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

Posted: Wed Feb 28, 2007 7:50 am
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.

Posted: Wed Feb 28, 2007 8:01 pm
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:

Posted: Wed Feb 28, 2007 8:15 pm
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.

Posted: Wed Feb 28, 2007 8:48 pm
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 :(

Posted: Wed Feb 28, 2007 9:00 pm
by kumar_s
But its easy to get the membership. By that you can help Dsxchange to help you.

Posted: Wed Feb 28, 2007 9:08 pm
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...

Posted: Wed Feb 28, 2007 9:18 pm
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.

Posted: Wed Feb 28, 2007 9:34 pm
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 :)

Posted: Thu Mar 01, 2007 12:18 am
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.

Posted: Thu Mar 01, 2007 12:41 am
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 :)