Lookup with Blank

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
just4geeks
Premium Member
Premium Member
Posts: 644
Joined: Sat Aug 26, 2006 3:59 pm
Location: Mclean, VA

Lookup with Blank

Post by just4geeks »

We have a situation where in certain conditions, I need to look up blank values with blank values.
How can we match Blank values coming from Hashed file with blank coming from source file.
' ' from source = ' ' from lookup? this is not working
Key field is defined as CHAR(2) in source as well as lookup.

Please suggest.

Thanks in advance!
Attitude is everything....
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

I would think it should work if both fields have two spaces in them, and I'm assuming that's what you mean by "blanks", yes?
-craig

"You can never have too many knives" -- Logan Nine Fingers
just4geeks
Premium Member
Premium Member
Posts: 644
Joined: Sat Aug 26, 2006 3:59 pm
Location: Mclean, VA

Post by just4geeks »

Thanks Craig.
Although Key column is defined as CHAR(2), When I am calculating the length of the blank column from Lookup file, Lenght is coming as 1. I am using function Len(Keycol). Thats why I think lookup is not matching. Any idea?

Thanks!
Attitude is everything....
just4geeks
Premium Member
Premium Member
Posts: 644
Joined: Sat Aug 26, 2006 3:59 pm
Location: Mclean, VA

Post by just4geeks »

Basically how blank values are coming as from Lookup Hashed file is my questions. are they coming as "" or " " ( one space) or " " ( 2 spaces) or any other value. Length function always returns 1 though for blank value.

Thanks,
Attitude is everything....
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Blanks are not modified or trimmed automatically in DataStage. A Char(2) definition will have length 2 regardless of contents, otherwise it is a VarChar column. Hmm, I just saw that you posted in PX but marked it as a server job. Data is not typed strictly in server and you could get a length of 1.

Code: Select all

LEN(Char(32):Char(32))
is going to be 2.
just4geeks
Premium Member
Premium Member
Posts: 644
Joined: Sat Aug 26, 2006 3:59 pm
Location: Mclean, VA

Post by just4geeks »

Data is not typed strictly in server and you could get a length of 1.
Code:
LEN(Char(32):Char(32))
is going to be 2.
Thanks Andrew!

It is indeed server job. I apologize for posting it to parallel forum. I am wondering how our situation can be handled if data type is not strictly followed in Server job. Any lights?

Thanks!
Attitude is everything....
just4geeks
Premium Member
Premium Member
Posts: 644
Joined: Sat Aug 26, 2006 3:59 pm
Location: Mclean, VA

Post by just4geeks »

Data is not typed strictly in server and you could get a length of 1.
Code:
LEN(Char(32):Char(32))
is going to be 2.
Thanks Andrew!

It is indeed server job. I apologize for posting it to parallel forum. I am wondering how our situation can be handled if data type is not strictly followed in Server job. Any lights?

Thanks!
Attitude is everything....
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Server is quite tolerant of diversity and doesn't run the police state that PX does so will quite happily put "OH NOES!" in a Char(2) or even a Decimal. The metadata wouldn't be enforced until it hits the target and then not always, depending on the target itself.

So the onus falls on you to ensure the metadata is enforced and a Char(2) doesn't have more or less than two characters in it. And having said that, if you are vigilant, your lookups should work fine, even "blank to blank".

ps. It's Arnd not Andrew. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
anu123
Premium Member
Premium Member
Posts: 143
Joined: Sun Feb 05, 2006 1:05 pm
Location: Columbus, OH, USA

Post by anu123 »

just4geeks wrote:
Data is not typed strictly in server and you could get a length of 1.
Code:
LEN(Char(32):Char(32))
is going to be 2.
Thanks Andrew!

It is indeed server job. I apologize for posting it to parallel forum. I am wondering how our situation can be handled if data type is not strictly followed in Server job. Any lights?

Thanks!

I would have a check on the particular field to see and MASK 'BLANK' values with a value that you never expect in that field say 'HI'. I think they match once you have masked blanks on both inbound and lookup streams.


Thanks
Thank you,
Anu
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

No need, "blanks" aka spaces work just fine here and are handled no different than any other character. Like all reference lookups, they just need their values to match on both 'sides' of the key, Char(2) to Char(2).

Just to put the last nail in this, I built a simple test job that creates a hashed file with a single record keyed by a Char(2) field populated with two spaces, then sent the same thing in as the input data. As expected, the lookup worked fine.
-craig

"You can never have too many knives" -- Logan Nine Fingers
just4geeks
Premium Member
Premium Member
Posts: 644
Joined: Sat Aug 26, 2006 3:59 pm
Location: Mclean, VA

Post by just4geeks »

Thanks Craig. You are right.

We have worked out the solution keeping limitation of Server Edition in Mind.

Thanks all who contributed and visited this topic.

Take care!
Attitude is everything....
Post Reply