How to get the substring from the string in DS transformer

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
sharma
Premium Member
Premium Member
Posts: 46
Joined: Mon Dec 24, 2007 2:16 pm

How to get the substring from the string in DS transformer

Post by sharma »

Hi ,

I want extract substring ( e.g starting from 4th place to 10th place ) from a giving string of length 100.

e.g.
Given String:

STR= "abcd,ef,ghi,jkl,123,4rf,gfr,ser.........."

I want to extract "ef" from the above mentione given string.

I want to check the substr(6,7) ='ef'.

How would i do in the datastage transformer.

Can somebody help me out.

Thanks
Nirmal Sharma
kandyshandy
Participant
Posts: 597
Joined: Fri Apr 29, 2005 6:19 am
Location: Singapore

Post by kandyshandy »

STR[6,2] will work
Kandy
_________________
Try and Try again…You will succeed atlast!!
srimitta
Premium Member
Premium Member
Posts: 187
Joined: Sun Apr 04, 2004 7:50 pm

Post by srimitta »

"abcd,ef,ghi,jkl,123,4rf,gfr,ser[6,2] = ef

Assuming data string is left justified, fetch 2 bytes from string position 6.
Quality is never an accident; it is always the result of high intention, sincere effort, intelligent direction and skillful execution; it represents the wise choice of many alternatives.
By William A.Foster
sharma
Premium Member
Premium Member
Posts: 46
Joined: Mon Dec 24, 2007 2:16 pm

Post by sharma »

There is no such function STR(x,y) in the DS.
Nirmal Sharma
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

They didn't say there was. The square brackets are the substring operators, so they showed how to take 2 characters from a field named STR starting from the 6th position.
-craig

"You can never have too many knives" -- Logan Nine Fingers
sharma
Premium Member
Premium Member
Posts: 46
Joined: Mon Dec 24, 2007 2:16 pm

Post by sharma »

Ohh!!!
Thanks ...Its working now.

Thank you very much.
Nirmal Sharma
Nagaraj
Premium Member
Premium Member
Posts: 383
Joined: Thu Nov 08, 2007 12:32 am
Location: Bangalore

Post by Nagaraj »

Sharma,

can you please post the code as well so that it is marked as completely solved.

Thanks
sharma
Premium Member
Premium Member
Posts: 46
Joined: Mon Dec 24, 2007 2:16 pm

Post by sharma »

here is the small piece of test code that i have written in the transformer stage to test my sample data.

If ( DSLink3.col1[5,2] ="xy") Then "valid" Else "invalid"
Nirmal Sharma
sharma
Premium Member
Premium Member
Posts: 46
Joined: Mon Dec 24, 2007 2:16 pm

Post by sharma »

here is the small piece of test code that i have written in the transformer stage to test my sample data.

If ( DSLink3.col1[5,2] ="xy") Then "valid" Else "invalid"
Nirmal Sharma
Nagaraj
Premium Member
Premium Member
Posts: 383
Joined: Thu Nov 08, 2007 12:32 am
Location: Bangalore

Post by Nagaraj »

Perfect thanks,

i just want all the issues or concerns discusssed here are marked as complete with solutions mentioned :)

Thanks once again.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Then it seems it is time to ask that the topic be marked as Resolved using the big button at the top of the screen. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply