Adding an 'IN' clause to the Filter Stage's where condition

Do you have features you'd like to see in future releases of DataStage, MetaStage, Parameter Manager, Version Control or one of the other tools represented on this forum? Post your ideas here!

Moderators: chulett, rschirm

Post Reply
bcarlson
Premium Member
Premium Member
Posts: 772
Joined: Fri Oct 01, 2004 3:06 pm
Location: Minnesota

Adding an 'IN' clause to the Filter Stage's where condition

Post by bcarlson »

I have a filter criteria where we need to check if a column has one of many different values. The ideal would be to use an IN clause, as you would use in a database. Right now that option does not exist, do you think it ever will?

Is the intent of the Filter Stage to allow 'SQL-like' where clauses? If so, you would think an 'IN' clause would be an obvious and necessary addition.

For now, I am stuck with

Code: Select all

field1 = 'Y'
and (
    field2 = 'A'
    or field2 = '#'
    or field2 = 'C'
    or field2 = 'H'
    or field2 = 'K'
    or field2 = '2'
)
My actual filter is more complex, but you get the idea. I really like keeping the 'where' logic in one place, but sure wish it could be simplified:

Code: Select all

field1 = 'Y'
and field2 in ('A', '#', 'C', 'H', 'K', 'Z')
An IN clause should obviously be able to handle any normal character or numeric datatype, just like a database.

Brad.
bcarlson
Premium Member
Premium Member
Posts: 772
Joined: Fri Oct 01, 2004 3:06 pm
Location: Minnesota

Post by bcarlson »

Allow me to add a clarification to my own posting. User vmcburney informed me of an adaptation of the LIKE clause that will help in my previous example:

Code: Select all

field1 = 'Y' 
and field2 LIKE [A#CHKZ]
However, a true IN clause would also handle numbers:

Code: Select all

field1 = 'N'
and field2 IN (100, 225, 237, 432, 786)
Brad.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

In server jobs (yes, I am aware Brad uses parallel jobs) there is a technique using a "range conversion" with Oconv. This returns the original string if it falls within one of the ranges in the second argument, or an empty string otherwise. To accomplise Brad's example you would use:

Code: Select all

Oconv(Argument,"R100,100;225,225;237,237;432,432;786,786")
I agree that an IN capability would be desirable in a parallel job Filter stage, particularly since the Information field says "an SQL-like constraint".
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
kris007
Charter Member
Charter Member
Posts: 1102
Joined: Tue Jan 24, 2006 5:38 pm
Location: Riverside, RI

Post by kris007 »

Likewise there should also be NOT IN clause so that we donot have to check col1<>10 AND col1<>20 and so forth.
Kris

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