Non-equijoin Key Expression

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

jjrbikes
Premium Member
Premium Member
Posts: 117
Joined: Tue Nov 25, 2003 11:09 am
Location: Minneapolis

Non-equijoin Key Expression

Post by jjrbikes »

Good Afternoon -

I'm definitely not firing on all cylinders today and need a little clarification. I've searched the forum - but can't find anything that directly addresses my current issue- so here it is:

I have a hashed file with Customer_Number as my key field.
I also have an input file with multiple columns - including My_Customer_Number, Your_Customer_Number, and Our_Customer_Number.

If I set my 'key_expression' as:

Code: Select all

My_Customer_Number OR Your_Customer_Number OR Our_Customer_Number
Will

Code: Select all

NOT(LookUpFile.NOTFOUND)
evaluate to True if My_Customer_Number = Customer_Number OR Your_Customer_Number = Customer_Number OR Our_Customer_Number = Customer_Number. :?

Thanks!
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

No. It wont.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
jjrbikes
Premium Member
Premium Member
Posts: 117
Joined: Tue Nov 25, 2003 11:09 am
Location: Minneapolis

Post by jjrbikes »

Talk about effective and efficient...thanks for that Guru. :cry:

So, can you help me out a bit here and tell me what I need to do to get the intended result? My hope is to use

Code: Select all

NOT(LookUpFile.NOTFOUND) And (X <> Y or P <> Q or A <> C)
as my constraint for one output file and

Code: Select all

LookUpFile.NOTFOUND
as my constraint for a second output file.

Thanks again.
paddu
Premium Member
Premium Member
Posts: 232
Joined: Tue Feb 22, 2005 11:14 am
Location: California

Post by paddu »

jjrbikes- truly did not understand your second post. :?
jjrbikes
Premium Member
Premium Member
Posts: 117
Joined: Tue Nov 25, 2003 11:09 am
Location: Minneapolis

Post by jjrbikes »

sorry -
My second post is asking for help. If the code I described in my first post will not create a True evaluation for

Code: Select all

NOT(LookUpFile.NOTFOUND)
- What do I need to do to my code to get the intended result?

In other words, how must I modify my 'key expression' in order to get

Code: Select all

NOT(LookUpFile.NOTFOUND)
to evaluate to TRUE when any one of three possible input columns match the key column on my hashed file?

Does that help?

Thanks
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

I have no idea what X, Y, P, Q, A and C are. Reading your second post, you can get that done with a custom routine. Something like

Code: Select all

      Retvalue=""

      Open "suresh" to myfile else ABORT

      Readu Retvalue from myfile, Arg1 else
         Readu Retvalue from myfile, Arg2 else
            Readu Retvalue from myfile, Arg3 else
               Retvalue = -1
            End
         End
      End

      Ans = Retvalue

    
Its very raw right now. You need to add error handling. This is just to give an idea.
Last edited by DSguru2B on Mon Feb 05, 2007 3:49 pm, edited 1 time in total.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
I_Server_Whale
Premium Member
Premium Member
Posts: 1255
Joined: Wed Feb 02, 2005 11:54 am
Location: United States of America

Post by I_Server_Whale »

You can have three reference links coming into the transformer from same the hashed file look-up.
One each for performing the lookup based on the three incoming fields.

HTH,
Whale.
Anything that won't sell, I don't want to invent. Its sale is proof of utility, and utility is success.
Author: Thomas A. Edison 1847-1931, American Inventor, Entrepreneur, Founder of GE
jjrbikes
Premium Member
Premium Member
Posts: 117
Joined: Tue Nov 25, 2003 11:09 am
Location: Minneapolis

Post by jjrbikes »

thanks -

X, Y, P, Q, A and C were just examples that there was more code to my second output file and I could therefore not simply use the "Reject Row" option. Really insignificant here.

On to the more important stuff.

If I'm reading your code correctly, this would search my hashed file for the three possible values in the input file, and if not found would return basically a LookUpFile.NOTFOUND value. Correct?

Thanks - I'll give this a try.
jjrbikes
Premium Member
Premium Member
Posts: 117
Joined: Tue Nov 25, 2003 11:09 am
Location: Minneapolis

Post by jjrbikes »

Thanks Whale -
that is actually how we currently have our process set up - but for some reason someone doesn't like that design and tasked me with making this work with only one link coming into the transformer.

I like the way you think!
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

jjrbikes wrote: If I'm reading your code correctly, this would search my hashed file for the three possible values in the input file, and if not found would return basically a LookUpFile.NOTFOUND value. Correct?
It will return a -1 if the value is not found. You can leverage that for LookUpFile.NOTFOUND
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
paddu
Premium Member
Premium Member
Posts: 232
Joined: Tue Feb 22, 2005 11:14 am
Location: California

Post by paddu »

jjrbikes

are you carrying these three source fields to target or are you carrying only the reference lookup (field ) to the target ? or not carrying any of these fields to the target only using them for selection of the data??

paddu
I_Server_Whale
Premium Member
Premium Member
Posts: 1255
Joined: Wed Feb 02, 2005 11:54 am
Location: United States of America

Post by I_Server_Whale »

Thanks!
jjrbikes wrote:that is actually how we currently have our process set up - but for some reason someone doesn't like that design
But Why? :? May I know the reason?
Whale.
Anything that won't sell, I don't want to invent. Its sale is proof of utility, and utility is success.
Author: Thomas A. Edison 1847-1931, American Inventor, Entrepreneur, Founder of GE
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Re: Non-equijoin Key Expression

Post by chulett »

jjrbikes wrote:If I set my 'key_expression' as:

Code: Select all

My_Customer_Number OR Your_Customer_Number OR Our_Customer_Number
Not even close to a valid Key Expression. An expression like this will resolve to one of two values: TRUE or FALSE. A zero or a one.

You can conditionally supply one of the three values to the field via something like this:

Code: Select all

If X Then My_Customer_Number Else If Y Then Your_Customer_Number Else Our_Customer_Number
If you want to look up all three you must use three reference links. Then it's a matter of checking the results in whatever dependancy order you may have.
-craig

"You can never have too many knives" -- Logan Nine Fingers
jjrbikes
Premium Member
Premium Member
Posts: 117
Joined: Tue Nov 25, 2003 11:09 am
Location: Minneapolis

Post by jjrbikes »

Good Morning -

Whale -
The only explanation provided was that it was "messy, hard to follow and even more difficult to debug and maintain". But, now I know for sure that this is truly the best, if not the only, way to write this piece of code.

Thanks to Everyone for your help on this! :wink:
bkerebel
Participant
Posts: 15
Joined: Wed Jan 05, 2005 3:18 am

Post by bkerebel »

hi,
if I have trouble about expressions like that, I do one variable for each TRUE expression, and then it's very easy to debug,

vars :
true_1 : if NOT(LookUpFile.NOTFOUND) then @true else @false
true_2 : X <> Y or P <> Q or A <> C then @true else @false
derivation :
true_1 AND true_2

and then your not_easy_someone will be happy to see that your work is so easy to debug

Bertrand
Post Reply