EXPRESS LIKE or NOT LIKE EXPRESSION

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
kayarsenal
Participant
Posts: 17
Joined: Mon Jan 16, 2006 2:11 pm
Contact:

EXPRESS LIKE or NOT LIKE EXPRESSION

Post by kayarsenal »

Hi,

I want to express LIKE or NOT LIKE in DataStage. For example I have an SQL statement like this:

select * from Y where X like 'Chels%'
select * from Y where X like '%Arsen%'
select * from Y where X not like '%ManU%'

How will this be represented in DS?

I thought of using MATCH(es)...

I want the where clause in the above SQL statement to be used in the transformer constraint condition...that is the first one would be:

X Matches 'Chels...' ( is it correct? )


the second:

X matches '...Arsen...' (is it correct?)

how would I represent the NOT LIKE though?

Regards,
ARSENAL GUNNERS GOONER
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Simple enough to test in a routine, yes? I believe you've got the syntax correct but for whatever reason I don't use that function all that much. Easy enough to test, however.

The online help should say if there is specific 'not' syntax. If there isn't, you can always use the 'Not' function to reverse the value of any expression.
-craig

"You can never have too many knives" -- Logan Nine Fingers
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Or specify the same constraint in one link and create a second link that will be reject link. Any row that doesnt go through the first link will pour down the reject link.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Pattern matching in server jobs uses neither SQL wildcards, which your examples use, nor regular expressions. Instead they have their own idiosyncratic patterns, which you can read about in the DataStage BASIC manual. To get you started, the "any" wildcard is either "0X" or "..." and the single character wildcard is "1X". You can specify that particular characters in the pattern must be alphabetic or numeric.

Thus X Matches "Chel..." will pick up Chelsea and Cheltenham, X Matches "...Arsen..." will be correct as well. Simply wrap a Matches operator in a Not() function to reverse its effect, for example Not(X Matches "...ManU...")

The pattern can be preceded by a tilde to reverse its effect, for example X Matches "~...ManU..." returns true for any X that does not contain "ManU".
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply