lookup with value and range value

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
kjaouhari
Participant
Posts: 325
Joined: Thu Mar 16, 2006 10:22 am

lookup with value and range value

Post by kjaouhari »

Hi guys !

I'm tryi,g to do a lookup with an input value and hasf file reference.
This hash file reference contains ranges values, this an simple example :
-------------------------
column1|column2
------------------------
1 to 10 |low
11 to 20|middle
21 to 30|high

So if input value is 9 the result will be "low", and if it's 25 the result except would be "high".

I know that I can generate all values (1,2,3,...30)and then perform my lookup directly...

But is it possible to do a lookup with value and range value ?

Thanks in advance !
Krazykoolrohit
Charter Member
Charter Member
Posts: 560
Joined: Wed Jul 13, 2005 5:36 am
Location: Ohio

Post by Krazykoolrohit »

try this. (one more roundabout approach)

add a transformer before lookup and convert all input values to range. ex: convert 9 to "1 to 10 " and then do the lookup using this field.

If (Field) <11 and (field) > 0 then "1 to 10" else if .............

I have never heard about a lookup on range.
kjaouhari
Participant
Posts: 325
Joined: Thu Mar 16, 2006 10:22 am

Post by kjaouhari »

I think I've understood your solution, but I can't convert input values to range, because range can change, and number of range can change to

"1 to 5" |low
"6 to 25"|middle
.... |high
"46 to 92"|very high

if input value is 9 the result will be "middle",
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Is there a database involved anywhere here? You could easily construct a table holding range name, low value and high value and then join to this on the way out using 'between' logic...
-craig

"You can never have too many knives" -- Logan Nine Fingers
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Even if a database is not involved, this data can be loaded into a temp table and then a user defined sql can be written on it. I think going this way would turn out to be a very dynamic/flexible solution in which you dont need to hardcode the range values.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
loveojha2
Participant
Posts: 362
Joined: Thu May 26, 2005 12:59 am

Post by loveojha2 »

Even if a database is not involved, this data can be loaded into a temp table and then a user defined sql can be written on it.
I agree with DSGuru, but instead of going for the database way, you can get it done through the Universe Stage (instead of your Hashed File) and do a range lookup there.
Success consists of getting up just one more time than you fall.
sb_akarmarkar
Participant
Posts: 232
Joined: Fri Sep 30, 2005 4:52 am
Contact:

Post by sb_akarmarkar »

As you have only 3 rows in lookup get all row in tansformer by hard coding column2 values and use Field() function and extract numeric values from column1(as you fix string like 1 to 10) and check input against that range....
hope this will work...


Thanks,
Anupam
kjaouhari
Participant
Posts: 325
Joined: Thu Mar 16, 2006 10:22 am

Post by kjaouhari »

Hi everybody !

I've found a solution, I use a custom routine that creating all values. And then I can use a look up, like Krazykoolrohit's solution
Post Reply