Page 1 of 1
Implementation of "like" function
Posted: Mon Mar 14, 2011 10:42 am
by adi_2_chaos
Hi,
I need to implement an SQL "like" functionality using datastage. e.g.. Capture all the rows
Is there any stage to be able to perform this?
Thanks & regards,
Sriram Garikapati
Posted: Mon Mar 14, 2011 11:19 am
by jwiles
Filter, transformer. See the Parallel Job Developer Guide chapters on both of these stages for usage and examples.
Regards,
Posted: Mon Mar 14, 2011 12:26 pm
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.
Posted: Mon Mar 14, 2011 12:40 pm
by DSguru2B
A simple substring and equality check can solve the issue if the character is in the first or last position
Posted: Mon Mar 14, 2011 8:19 pm
by adi_2_chaos
Thanks All.