left outer join and where caluse

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
times29
Premium Member
Premium Member
Posts: 202
Joined: Mon Sep 22, 2008 3:47 pm

left outer join and where caluse

Post by times29 »

Hi,
I have

Code: Select all

 table a                          table b
col1   col2  col             col1  b_col2   b_col3
105    500   507             105   500      507
105    500   506
105    101   201
Target result should be

Code: Select all

col1 col2 col3
105  500  506
105  101  201
i joined two table using join stage did left outer join from table a to table b on col1 then in transformer i put a constraint
col2<>b_col2 and col3<>b_col3 and the constraint is not working as it filter all three table a records

any idea what i am doing wrong?

Thanks
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Do you get three rows into the Transformer stage?

What would you expect the result to be?

The correct test for a failed lookup would be IsNull(col2).
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
times29
Premium Member
Premium Member
Posts: 202
Joined: Mon Sep 22, 2008 3:47 pm

Post by times29 »

Yes transformer did get three rows in which is good but after transformer
constraint rows_out are zero

i want to see two below rows out of transformer

105 500 506
105 101 201
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

So your incoming data to the transform stage after the join is

Code: Select all

col1   col2  col3  b_col2  b_col3 
105    500   507  500      507 
105    500   506  500      507 
105    101   201  500      507 
Your logic in the constraint would seem to be correct. Try to remove the right side of the "AND" and see if you get the expected 1 output row; then repeat for the left side to see if you get the expected 2 output rows.
PhilHibbs
Premium Member
Premium Member
Posts: 1044
Joined: Wed Sep 29, 2004 3:30 am
Location: Nottingham, UK
Contact:

Re: left outer join and where caluse

Post by PhilHibbs »

times29 wrote:Target result should be

Code: Select all

col1 col2 col3
105  500  506
105  101  201
Why should this be the output? What's the rule that rejects the second row? At a guess, I'd be tempted to say "where col2<>b_col2 or (col2=b_col2 and col3=b_col3)", is that it? In english, "if Col2 matches then Col3 has to match as well".
Phil Hibbs | Capgemini
Technical Consultant
ankursaxena.2003
Participant
Posts: 96
Joined: Mon May 14, 2012 1:30 pm

Post by ankursaxena.2003 »

Are you using Join Stage to join both the tables.

If you are using Join Stage then can you check link ordering in Join Stage.
I think link from Table b is doing left join with Table a.
stuartjvnorton
Participant
Posts: 527
Joined: Thu Apr 19, 2007 1:25 am
Location: Melbourne

Post by stuartjvnorton »

I think you need to explain what you actually want. Just giving a trivial example means that we can come up with too many different ways to interpret it, and therefore too many solutions.

Do you want everything from table 1 that isn't in table 2?
Post Reply