Implementation of "like" function

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
adi_2_chaos
Participant
Posts: 96
Joined: Fri Apr 17, 2009 5:58 am
Location: Delhi

Implementation of "like" function

Post by adi_2_chaos »

Hi,

I need to implement an SQL "like" functionality using datastage. e.g.. Capture all the rows

Code: Select all

where name like 'A%'
Is there any stage to be able to perform this?

Thanks & regards,
Sriram Garikapati
jwiles
Premium Member
Premium Member
Posts: 1274
Joined: Sun Nov 14, 2004 8:50 pm
Contact:

Post by jwiles »

Filter, transformer. See the Parallel Job Developer Guide chapters on both of these stages for usage and examples.

Regards,
- james wiles


All generalizations are false, including this one - Mark Twain.
cecilia
Participant
Posts: 33
Joined: Thu Jan 15, 2004 9:55 am
Location: Argentina
Contact:

Post by cecilia »

Hi Sriram
Check if with Index function you can solve what you need:
Index Function
Returns the starting position of a substring.

Syntax
Index (string, substring, instance)string is the string or expression containing the substring. If string is a null value, 0 is returned.

substring is the substring to be found. If substring is an empty string, 1 is returned. If substring is a null value, 0 is returned.

instance specifies which instance of substring is to be located. If instance is not found, 0 is returned. If instance is a null value, it generates a runtime error.

Examples
The following examples show several ways of finding the position of a substring within a string:

MyString = "P1234XXOO1299XX00P1"
Position = Index(MyString, 1, 2)
* The above returns the index of the second "1" character (10).
Position = Index(MyString, "XX", 2)
* The above returns the start index of the second "XX"
* substring (14).
Position = Index(MyString, "xx", 2)
* The above returns 0 since the substring "xx" does not occur.
Position = Index(MyString, "XX", 3)
* The above returns 0 since the third occurrence of

Regards
Cecilia
* substring "XX" * cannot be found.
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

A simple substring and equality check can solve the issue if the character is in the first or last position

Code: Select all

in.name[1,1] = 'A'
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
adi_2_chaos
Participant
Posts: 96
Joined: Fri Apr 17, 2009 5:58 am
Location: Delhi

Post by adi_2_chaos »

Thanks All.
Post Reply