SQL Logic

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
kpsita
Participant
Posts: 99
Joined: Tue Jul 21, 2009 11:43 pm

SQL Logic

Post by kpsita »

Hi,

I have a simple sql logic which I have to implement in Datastage.
The sql is
Select * from table A
where A.Field1 NOT IN (Select Field1 from Table B)

How do I implement this logic in datastage. I know if it in IN table B then I can use inner join to get result. But if it is NOT IN then how do I get this implemented.I am asking this because in the above case Table1 is a file and table B is a table.

Thanks!!!!
KPSITA
anbu
Premium Member
Premium Member
Posts: 596
Joined: Sat Feb 18, 2006 2:25 am
Location: india

Post by anbu »

Use Lookup stage and set Lookup Failure to Reject. Lookup reject link gives the records from file which is not there in table
You are the creator of your destiny - Swami Vivekananda
kris007
Charter Member
Charter Member
Posts: 1102
Joined: Tue Jan 24, 2006 5:38 pm
Location: Riverside, RI

Re: SQL Logic

Post by kris007 »

And feed the output link of the LookUp Stage to a Copy Stage or Sequential file stage with path /dev/null
Kris

Where's the "Any" key?-Homer Simpson
dougcl
Premium Member
Premium Member
Posts: 137
Joined: Thu Jun 24, 2010 4:28 pm

Re: SQL Logic

Post by dougcl »

kris007 wrote:And feed the output link of the LookUp Stage to a Copy Stage or Sequential file stage with path /dev/null
Does this encourage garbage collection?
kpsita
Participant
Posts: 99
Joined: Tue Jul 21, 2009 11:43 pm

Post by kpsita »

Thanks for your reply. But can I use lookup if the reference table is in millions. Is there any other options other than lookup.

Thanks
KPSITA
kris007
Charter Member
Charter Member
Posts: 1102
Joined: Tue Jan 24, 2006 5:38 pm
Location: Riverside, RI

Post by kris007 »

dougcl wrote: Does this encourage garbage collection?
I am not sure I follow you. Output link for the lookup stage is a required link. And since the OP is interested only in the data from the reject link, its a good option to write the data from the output link into /dev/null or a copy stage without an output link as it is not necessary.
Kris

Where's the "Any" key?-Homer Simpson
kris007
Charter Member
Charter Member
Posts: 1102
Joined: Tue Jan 24, 2006 5:38 pm
Location: Riverside, RI

Post by kris007 »

kpsita wrote:Thanks for your reply. But can I use lookup if the reference table is in millions. Is there any other options other than lookup.
Thanks
Depends on how big your table is, how many columns you are bringing in, how large the memory is, and how fast your reference table is growing in terms of records.
Kris

Where's the "Any" key?-Homer Simpson
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Why not simply use your SQL as is?
-craig

"You can never have too many knives" -- Logan Nine Fingers
kpsita
Participant
Posts: 99
Joined: Tue Jul 21, 2009 11:43 pm

Post by kpsita »

I can't use the sql as such because my master source is a file.

Thanks
KPSITA
anbu
Premium Member
Premium Member
Posts: 596
Joined: Sat Feb 18, 2006 2:25 am
Location: india

Post by anbu »

Did you try the Lookup?
You are the creator of your destiny - Swami Vivekananda
kris007
Charter Member
Charter Member
Posts: 1102
Joined: Tue Jan 24, 2006 5:38 pm
Location: Riverside, RI

Post by kris007 »

kpsita wrote:I can't use the sql as such because my master source is a file.Thanks
A solution has already been provided by anbu and myself.
Kris

Where's the "Any" key?-Homer Simpson
Post Reply