Page 1 of 1

Replace a string with another string

Posted: Mon Jun 09, 2014 6:50 am
by MANASHI
Hi All,
I have a requirement to replace a string with another string or just removing that string in datastage 8.5. And that string may appear more than once. Is there any function in DS 8.5 which does this? Please let me know. From this forum I got to know that we can write a routine to do this. But I was just wondering if there are any built in functionality to do this.

Posted: Mon Jun 09, 2014 6:55 am
by chulett
Split off from this conversation on the same topic. And the answer is still no until you get up into the 9.x release, from what I recall.

Posted: Mon Jun 09, 2014 7:12 am
by MANASHI
Do we have any other work around using index, left, right? But probably in that case also, we will have to loop through. :(

Posted: Mon Jun 09, 2014 7:27 am
by chulett
You... could, I imagine. Seems like it would be fairly painful, though. I would think the PXEReplace function linked to in the other post would be a better option.

Posted: Mon Jun 09, 2014 7:32 am
by MANASHI
Thanks. I also feel so.
Do you have the BASIC code for erplace function for parallel jobs? Could you please share that?

Posted: Mon Jun 09, 2014 8:08 am
by chulett
Others might but I no longer do.

Posted: Mon Jun 09, 2014 12:38 pm
by vik1979
Yes, I think you can use Ereplace function in transformer stage.

Posted: Mon Jun 09, 2014 1:31 pm
by chulett
A BASIC Transformer stage, sure. That's another option.

Posted: Mon Jun 09, 2014 5:38 pm
by ray.wurlod
pxEreplace() is a parallel function created for and improved on this site. A Search should find it for you.

Posted: Mon Jun 09, 2014 5:59 pm
by chulett
As noted, there's a link to it in the post this was split from. However, I seem to remember chatter there about memory leaks and other issues with it when Phil played with it last. [shrug]

Posted: Mon Jun 09, 2014 11:29 pm
by MANASHI
Thank you so much. I will try the basic transformer stage first. Do we have any disadvantages on that? I think it runs sequentially.

Posted: Tue Jun 10, 2014 3:48 am
by atul9806
Yes, Use of basic transformer in parallel job have some drawbacks but It DEPENDS.. About your questions - No, It is running Parallel ( by default ) as well as Sequencial. The Only drawback is It will invoke the SERVER ENGINE for executing the BASICs function used in BASIC transformer.

px version of Ereplace()
viewtopic.php?t=106358

Posted: Tue Jun 10, 2014 2:55 pm
by ssnegi
String INPUT.COL : This is a String.This should be used.This is good.
stage variable :
cnt : count(INPUT.COL,'This')
Loop Variable :
cnt1 Initial Value 0 : if cnt1 = 0 then cnt else cnt1-1
lfind1 :
if cnt1 = cnt then field(INPUT.COL,'This',1):'That':INPUT.COL[Index(INPUT.COL,'This',1)+len('This'),len(INPUT.COL)]else field(lfind1,'This',1):'That':lfind1[Index(lfind1,'This',1)+len('This'),len(lfind1)]
Loop While : cnt1 <> 1
Constraint : cnt1 = 1
OUTPUT : That is a String.That should be used.That is good.
The "This" recurring string is replaced with "That". You can use the same logic to remove the string. Instead of 'That' put ''.