Look up based on two conditions

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
Das
Participant
Posts: 87
Joined: Tue Oct 24, 2006 9:58 pm
Location: india

Look up based on two conditions

Post by Das »

Hi,

I have an issue as follows.

I have 2 source[1 flat file, 1 table].I need to look up the for data coming from the flat file to the table based on the following conditions:
If the field1 in the flat file is equal to Col2 or Col3 of the table .i need to pass the curresponding Col1 [the key column of the table]

Provide me a solution.
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

Two lookups, use the results of one else if none then use the other.
Kenneth Bland

Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
Das
Participant
Posts: 87
Joined: Tue Oct 24, 2006 9:58 pm
Location: india

Post by Das »

kcbland wrote:Two lookups, use the results of one else if none then use the other. ...
Thanks,
I have used two hashed file lookups,And use the following logic in output column of transformer :
If not(IsNull(DSLink86.Col1))
then
Unit_Out.Col1
Else
if not(IsNull(DSLink89.Col1)) then DSLink89.Col1
else @NULL

DSLink86.Col1,DSLink89.Col1 are input links from lookups populating based on the first condition and second condition

But the matched data is not populating
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

Shouldn't

Code: Select all

If not(IsNull(DSLink86.Col1)) 
then 
Unit_Out.Col1 
Else 
if not(IsNull(DSLink89.Col1)) then DSLink89.Col1 
else @NULL 

be

Code: Select all

If not(IsNull(DSLink86.Col1)) 
then 
DSLink86.Col1 
Else 
if not(IsNull(DSLink89.Col1)) then DSLink89.Col1 
else @NULL 
Kenneth Bland

Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
Das
Participant
Posts: 87
Joined: Tue Oct 24, 2006 9:58 pm
Location: india

Post by Das »

kcbland wrote:Shouldn't

Code: Select all

If not(IsNull(DSLink86.Col1)) 
then 
Unit_Out.Col1 
Else 
if not(IsNull(DSLink89.Col1)) then DSLink89.Col1 
else @NULL 

be

[code ...
I am not geeting you exatly..Please expalin
Das
Participant
Posts: 87
Joined: Tue Oct 24, 2006 9:58 pm
Location: india

Post by Das »

Thanks,
I have used two hashed file lookups,And use the following logic in output column of transformer :
If not(IsNull(DSLink86.Col1))
then
Unit_Out.Col1
Else
if not(IsNull(DSLink89.Col1)) then DSLink89.Col1
else @NULL

DSLink86.Col1,DSLink89.Col1 are input links from lookups populating based on the first condition and second condition

But the matched data is not populating and getting the following warning
also

DataStage Job 657 Phantom 11508
Program "DSD.StageRun": Line 544, Attempted WRITE with NULL record ID
DataStage Phantom Finished
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

The warning means you are attempting to write a hashed file record with NULL key values. You need to ensure that does not happen, either by supplying a default value when null or using a constraint to filter them out.
-craig

"You can never have too many knives" -- Logan Nine Fingers
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

Look again at my previous reply. You have the wrong link name.
Kenneth Bland

Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
rogue
Premium Member
Premium Member
Posts: 7
Joined: Wed Dec 27, 2006 11:26 am
Location: Essen

Re: Look up based on two conditions

Post by rogue »

Das wrote:I have 2 source[1 flat file, 1 table].I need to look up the for data coming from the flat file to the table based on the following conditions:
If the field1 in the flat file is equal to Col2 or Col3 of the table .i need to pass the curresponding Col1 [the key column of the table]


What about normalising the lookup before comparing?

Take the two columns to compare and make only one key column of them.


Best regards
Andreas
rafik2k
Participant
Posts: 182
Joined: Wed Nov 23, 2005 1:36 am
Location: Sydney

Post by rafik2k »

What are the datatypes of those columns,
If these are varchar then some time don't match due to trailing blank space.
In that case use trim(field1) function in Key Expression.
Post Reply