index constraint

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

index constraint

Post by times29 »

Hi,
I want to filter any records which has ___Req% or ___Joi%
i am putting constraint in transformer its not working

Index((to_transf._ID), "___Req",1)
or Index((to_transf._ID), "___Joi",1) = 0

Thanks
pandeesh
Premium Member
Premium Member
Posts: 1399
Joined: Sun Oct 24, 2010 5:15 am
Location: CHENNAI, TAMIL NADU

Post by pandeesh »

It seems you need to concatenate the search string like this:

Code: Select all

"_" : "Joi"

"_" : "Reqi"
pandeeswaran
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

For any kind of "starts with" check, all you need to do is substring.

Code: Select all

to_transf._ID[1,6] = "___Req"
-craig

"You can never have too many knives" -- Logan Nine Fingers
pandeesh
Premium Member
Premium Member
Posts: 1399
Joined: Sun Oct 24, 2010 5:15 am
Location: CHENNAI, TAMIL NADU

Post by pandeesh »

oh!i got it wrong.. i thought that he is searching for the string which contains '_' as a character in that string..
pandeeswaran
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

You missed the value comparison for the first Index() function. And you probably want "And" rather than "Or" if you want to exclude these records (it's not clear what you mean by "filter").

Code: Select all

Index((to_transf._ID), "___Req",1) = 0 And Index((to_transf._ID), "___Joi",1) = 0
If you want to include only these records, change the expression appropriately.

Code: Select all

Index((to_transf._ID), "___Req",1) <> 0 Or Index((to_transf._ID), "___Joi",1) <> 0
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 »

I want to do sumthing like this in sql so that records for _Req and _Joi not pass.i tried and suggested by ray its not working

SELECT *
FROM aa
where "ID" NOT like '___Req%' AND
"ID" NOT like '___Joi%'
nbalegar
Participant
Posts: 9
Joined: Fri Jul 08, 2011 2:47 am

Post by nbalegar »

You want to do it in sql or in datastage. If in datastage means you can use the filter stage which accepts the same format as you are using in the example above.
suse_dk
Participant
Posts: 93
Joined: Thu Aug 11, 2011 6:18 am
Location: Denmark

Post by suse_dk »

Put this in a stage variable and use the result to define the constraint.

If Index('___Joi|___Roi', to_transf._ID[1,6], 1) Then 1 Else 0
Post Reply