Lookup failing though data exists

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
Latha1919
Premium Member
Premium Member
Posts: 178
Joined: Mon May 22, 2006 2:32 pm

Lookup failing though data exists

Post by Latha1919 »

Hi,

In the current project, we have a job processing the .csv files (source is the .csv file) and finally loads the data into SQL database. Within the .csv file, have the data of varchar data type, mostly names fields. After fetching the data from this file, these names fields data will be looked up in the SQL database tables, and will be retrieving the corresponding ID field values, when the names exist.

Issue is: In the .csv file one name field has a valid name. This name does exist in the SQL dataabase, but the lookup is failing, hence this record is getting rejected. When I queried the database for this name (copied the name from .csv file), its not returning any rows. But if I type the same name manually in the Query Analyzer and execute the query, then it's returning the record.

But both the names are same. But, why its not returning teh record in the first case.

Please advise.

Thanks,
dsx
narasimha
Charter Member
Charter Member
Posts: 1236
Joined: Fri Oct 22, 2004 8:59 am
Location: Staten Island, NY

Post by narasimha »

My first try would be to trim the field and do a lookup
Narasimha Kade

Finding answers is simple, all you need to do is come up with the correct questions.
Latha1919
Premium Member
Premium Member
Posts: 178
Joined: Mon May 22, 2006 2:32 pm

Post by Latha1919 »

If I consider the execution of queries in the Query Analyzer;
when I use the name value from .csv file, query is not returning any rows. But when I reenter the same name in query analyzer and execute it, its returning row.
Why is that?
dsx
narasimha
Charter Member
Charter Member
Posts: 1236
Joined: Fri Oct 22, 2004 8:59 am
Location: Staten Island, NY

Post by narasimha »

This is strange, as the names are the same!
When you are copying from the .csv file are you copying some blank spaces too...
Try to trim the value and see if you get results
Narasimha Kade

Finding answers is simple, all you need to do is come up with the correct questions.
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Trim it. When your re-enter it manually you are omitting the blank spaces. Thats why this behaviour.
Try trimming the incoming data and then perform the lookup.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
DeepakCorning
Premium Member
Premium Member
Posts: 503
Joined: Wed Jun 29, 2005 8:14 am

Post by DeepakCorning »

Usually occurs when the CSV files have extra spaces in between the names or after or before the name. Trim may remove the issue but u will have to put trim in both the stages , lookup ad well the source or the names which have spaces in the DB will get rejected.

Testing - You can change the query by saying :LIKE the value you copied from teh CSV file and go on removing the spaces and see what exactly is stored in the DB and what is in CSV.
Post Reply