Hi,
The requirement is that a string like "1.1.1" or "1.1.1.2" will be read from an input file. There are two hash files called level3 and level4. The string can be found either in level3 file or level4 file. This depends on whther string is 3rd level ("1.1.1") or 4th level ("1.1.1.2"). But same string cannot be available in both the hash files.
If the string is found in level3 file, some processing need to be done. If the string is found in level4 file, some other processing need to be done.
I thought if I can write a subroutine where in I can open both the hash files and do the lookup, then the job will be compact with only one transformer.
Is it possible to open and do lookup on hash file using basic code?
If so Can some body give me a code snippet to do it?
Thanks in advance.
Regards
kmk143
How to open and do lookup in a hashfile from a routine
Moderators: chulett, rschirm, roy
While you could write a routine to do this, there's no reason to do so. All you need is one transformer, so the job will still be 'compact'.
Simply use a single transformer, two hash file lookup stages and two reference links back to that single transformer. Use the same field in both key fields and then check them both in the derivation for the target field. Based on the success or failure of each lookup, you can do your processing.
Does that make sense? Perhaps your 'processing' could be encapsulated into a routine so this can all stay inside one transformer...
![Wink :wink:](./images/smilies/icon_wink.gif)
Simply use a single transformer, two hash file lookup stages and two reference links back to that single transformer. Use the same field in both key fields and then check them both in the derivation for the target field. Based on the success or failure of each lookup, you can do your processing.
Does that make sense? Perhaps your 'processing' could be encapsulated into a routine so this can all stay inside one transformer...
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers
-
- Participant
- Posts: 81
- Joined: Wed Jul 14, 2004 3:18 am
- Location: Johannesburg, South Africa
- Contact:
In that case, perhaps you may want to use more than one transformer. It will make your life easier and the life of whoever has to maintain the job in future.
Pass the first transformer's two outputs, from constraints: or
(whichever you fancy) to two seperate transformers, where you can then do your other lookups.
Pass the first transformer's two outputs, from constraints:
Code: Select all
level3.NOTFOUND and level4.NOTFOUND
Code: Select all
Not(level3.NOTFOUND) and Not(level4.NOTFOUND)
Morney le Roux
There are only 10 kinds of people: Those who understand binary and those who don't.
There are only 10 kinds of people: Those who understand binary and those who don't.
Thank you. May be I need to be more clear on the requirement.
I need to do lookups on the same hash file for 10 input values. In general I need to have 10 instances of the hash file stage in my job. Instead if I can write a routine where the input values can be passed as a string. Thus we access the hash file with in the routine and can lookup the inputs. Here I believe we need to open hash file one time. Hence I want to know how to open and do a lookup on hash file through basic code.
Thanks in advance
kmk143
I need to do lookups on the same hash file for 10 input values. In general I need to have 10 instances of the hash file stage in my job. Instead if I can write a routine where the input values can be passed as a string. Thus we access the hash file with in the routine and can lookup the inputs. Here I believe we need to open hash file one time. Hence I want to know how to open and do a lookup on hash file through basic code.
Thanks in advance
kmk143