How to implement "Not In" function in Filter Stage

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
tjhaosse
Participant
Posts: 10
Joined: Sun Jun 11, 2006 6:45 am
Location: HongKong

How to implement "Not In" function in Filter Stage

Post by tjhaosse »

I have a SQL like

"a not in ('1','2','3')"

because some reason, i "MUST" use datastage job only to do this SQL statement.

can anyone know how to use filter stage(maybe transformer stage...) to implement "Not in" in PX job?
AmeyJoshi14
Participant
Posts: 334
Joined: Fri Dec 01, 2006 5:17 am
Location: Texas

Post by AmeyJoshi14 »

Hi,
In the filter stage you can use '<>' along with 'and' operator. :)
For example:
Suppose in my fisrt link i want only those employee who Employee number are not in 2 and 6..then this logic can implemented i filter as :

Code: Select all

EMP_NO <> 2 AND EMP_NO <> 6
Output link=(link where you want to pass this records)
Hope this will help you out! :wink:
http://findingjobsindatastage.blogspot.com/
Theory is when you know all and nothing works. Practice is when all works and nobody knows why. In this case we have put together theory and practice: nothing works. and nobody knows why! (Albert Einstein)
tjhaosse
Participant
Posts: 10
Joined: Sun Jun 11, 2006 6:45 am
Location: HongKong

Post by tjhaosse »

Thanks AmeyJoshi

But If my sql statement had many many case like:

Not in ('1','a',....etc...to much @_@)

can you teach me how should i do ?
AmeyJoshi14 wrote:Hi,
In the filter stage you can use '<>' along with 'and' operator. :)
For example:
Suppose in my fisrt link i want only those employee who Employee number are not in 2 and 6..then this logic can implemented i filter as :

Code: Select all

EMP_NO <> 2 AND EMP_NO <> 6
Output link=(link where you want to pass this records)
Hope this will help you out! :wink:
gabrielac
Participant
Posts: 29
Joined: Mon Sep 26, 2005 3:39 pm

Post by gabrielac »

One possibility would be to create a source file with all the possible values, then use a lookup stage, and filter stage to filter those that were not found.

HTH, Gaby
AmeyJoshi14
Participant
Posts: 334
Joined: Fri Dec 01, 2006 5:17 am
Location: Texas

Post by AmeyJoshi14 »

gabrielac wrote:One possibility would be to create a source file with all the possible values, then use a lookup stage, and filter stage to filter those that were not found.

HTH, Gaby
Oops my bad! :oops:
But the post by gabrielac is really amazing.. :D
I am gona ask this question in the interviews.. and that's the answer 8)
Just kidding!:lol: :lol:
http://findingjobsindatastage.blogspot.com/
Theory is when you know all and nothing works. Practice is when all works and nobody knows why. In this case we have put together theory and practice: nothing works. and nobody knows why! (Albert Einstein)
Post Reply