search function

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
sainath
Premium Member
Premium Member
Posts: 138
Joined: Fri Nov 19, 2004 3:57 pm

search function

Post by sainath »

Hi
I am wondering is there any scan or search function which searches for perticular key word .
Like i want to populate all data which matches with 'ADDED XXX' in a column.
THKS
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

The lookup methodolgy is the best to suit your needs. If you need something specific then be more elaborate on your question.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
chucksmith
Premium Member
Premium Member
Posts: 385
Joined: Wed Jun 16, 2004 12:43 pm
Location: Virginia, USA
Contact:

Post by chucksmith »

Take a look at the Index() function. It will return a non-zero value if the substring you are searching for is found in the string.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

That non-zero value that Index() returns is actually the starting position of the sub-string if it is found. The nice thing about that is, if you don't care where the sub-string is found but only if it is found, you can use that as a boolean. For example:

Code: Select all

If Index(Link.Column,'ADDDED',1) Then <do something> Else < do something else>
If 'ADDED' is not found in the column it will return a zero which is interpreted as False. And since any non-zero value evaulates to 'true', the starting position of the sub-string can be leveraged as indicated.

Hope that helps,
-craig

"You can never have too many knives" -- Logan Nine Fingers
gateleys
Premium Member
Premium Member
Posts: 992
Joined: Mon Aug 08, 2005 5:08 pm
Location: USA

Post by gateleys »

Try:

Code: Select all

If(InLink.Column MATCHES "0x'ADDED'0x") Then someValue Else otherValue
gateleys
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Gateleys,

for your information, although the MATCHES function will work; it uses 32 times more CPU than the INDEX function and that will add up to a lot slower execution or heavier CPU load in a real job.
gateleys
Premium Member
Premium Member
Posts: 992
Joined: Mon Aug 08, 2005 5:08 pm
Location: USA

Post by gateleys »

Agreed. :) Arnd, can you please give a brief comparison between the various comparison/search functions (in terms of efficiency)? And also, scenarios when each would be effective? Would be really neat.

gateleys
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

The INDEX function is used frequently and has been very well tuned. It is also (algorithmically) quite a simple linear search for a substring so is easy to implement. The MATCHES function is much a more complex pattern matching function which has to parse the picture string into it's components and then search the string for all components to match. You should use MATCHES or MATCHFIELD or the other pattern matches when a simple INDEX doesn't suffice.

Your matches idea was good, I just wanted to make sure that it was understood that there is a price to pay for that flexibility.
Post Reply