To find out the substring and concat with field separator

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
muralisankarr
Premium Member
Premium Member
Posts: 83
Joined: Tue Oct 28, 2008 1:55 am
Location: Chennai

To find out the substring and concat with field separator

Post by muralisankarr »

Hi,

I have a column DESC_ which has values like the below one

DESC_
-----------
ABC
ABCXYZ
XYZ
NULL
ZZZAAABBB

I need to append comma after every 3 character.
DESC_
-----------
ABC
ABC,XYZ
XYZ
NULL
ZZZ,AAA,BBB

Please hint me with some logic to accomplish this.

Many Thanks
MSR
The minute you start talking about what you're going to do if you lose, you have lost
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Use a BASIC Transformer stage and the following expression:

Code: Select all

Convert(@FM, ",", Fold(InLink.DESC_, 3))
or this one:

Code: Select all

Convert(@TM, ",", Fmt(InLink.DESC_, "3L"))
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
prasoon
Participant
Posts: 29
Joined: Thu Mar 30, 2006 6:43 am

Post by prasoon »

This will also give the same result
Ereplace(Fold(InLink.DESC_,3),@FM,',')
Regards,
Prasoon
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

... which still requires a BASIC Transformer stage because of the Fold() function. Further, Convert() is a more lightweight function than Ereplace().
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