Like statement in transformer

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
jpockets
Participant
Posts: 12
Joined: Tue Mar 14, 2006 11:19 am

Like statement in transformer

Post by jpockets »

I have a mircosoft Access database that picks up a file and formats it into a sequential file for me. That sequential file is than ftp to the server and datastage runs. This job is only run once a month. There was a request to change one of the columns and i need to use a like statement i tried to do it in access but it blew up saying it was too complex.

I need to do something like this if(input_colum like '*MND*' ) than MND else if(input_column like '*Puni*Wrap*' than "Puni Wrap' else input_column, (it keeps going but i will stop there) i know there is a match function in datastage but that didn't work, is there a way to do this in the transformer? Or can you use the match function with the wild card?

Thanks for the help...
gateleys
Premium Member
Premium Member
Posts: 992
Joined: Mon Aug 08, 2005 5:08 pm
Location: USA

Re: Like statement in transformer

Post by gateleys »

Lookup your Help for the Matches function.
gateleys
jpockets
Participant
Posts: 12
Joined: Tue Mar 14, 2006 11:19 am

Post by jpockets »

I looked at the help for matches is this what i found

pattern must contain elements that describe all the characters in string. For example, the following statement returns an empty string because pattern does not cover the substring "AB" at the end of string:

MatchField ("XYZ123AB", "3X3N", 1)

I'm not sure what the "3X3N", 1 is supposed to represent. I guess what i need is for "3X3N" to represent a wildcard, has anybody ever used something like that before?
gateleys
Premium Member
Premium Member
Posts: 992
Joined: Mon Aug 08, 2005 5:08 pm
Location: USA

Post by gateleys »

jpockets wrote:I looked at the help for matches is this what i found

pattern must contain elements that describe all the characters in string. For example, the following statement returns an empty string because pattern does not cover the substring "AB" at the end of string:

MatchField ("XYZ123AB", "3X3N", 1)

I'm not sure what the "3X3N", 1 is supposed to represent. I guess what i need is for "3X3N" to represent a wildcard, has anybody ever used something like that before?
'X' refers to alphabet or numeric, whatever. So, you probably now know what 'N' and 'A' are. The digit refers to the 'number' of characters. You may also want to try this simple way -

Code: Select all

To check for "pose" in the string "supposed to represent", use -
Link.InputString Matches "...pose..."
gateleys
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

There's also Index if you want to find a substring inside a string, but your first Matches would need '...MDN...' I believe. '3X3N' means any three characters followed by any three numbers.
-craig

"You can never have too many knives" -- Logan Nine Fingers
jpockets
Participant
Posts: 12
Joined: Tue Mar 14, 2006 11:19 am

Post by jpockets »

Thank-you for the help. it worked when i used the ... .... I got thrown off by the help file, i wasn't really sure where they were going with that. Thanks again for the help
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

You should also have found the Matches operator in your trawl through on-line help.

Code: Select all

InLink.TheColumn Matches "...MND..." 
would do it, as would

Code: Select all

InLink.TheColumn Matches "0X'MND'0X"
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