Hi,
I need to do the following in datastage
input string
lmundada%3Dabc%3Dlmno%2D
I need to replace all '%3D' with ':' and all %2D with ','
output string
lmundadalmno,
I used convert function but convert function converts all occurances of % to :.
I need to do something similar to replace function in oracle.
Since I am using datastage px, I cannot use the ereplace or the change function, which need the basic transformer to be used.
regards,
varsha
Replacing a substr with a single value
Moderators: chulett, rschirm, roy
-
- Participant
- Posts: 48
- Joined: Thu Mar 11, 2004 10:32 pm
-
- Participant
- Posts: 437
- Joined: Fri Oct 21, 2005 10:00 pm
Re: Replacing a substr with a single value
Try Convert('%3D',':',Input.String). that should work to replace your first string. Use stage variables and convert once for the %3D value and again for the next value. You might try nesting the function, but I like using stage variables instead makes it easier to read later. Let me know if this works for you,
Keith Williams
keith@peacefieldinc.com
keith@peacefieldinc.com
-
- Participant
- Posts: 48
- Joined: Thu Mar 11, 2004 10:32 pm
Re: Replacing a substr with a single value
The problem is the Convert function is replacing even %2D along with the %3D, as it encounters % and is replacing it with :kwwilliams wrote:Try Convert('%3D',':',Input.String). that should work to replace your first string. Use stage variables and convert once for the %3D value and again for the next value. You might try nesting the function, but I like using stage variables instead makes it easier to read later. Let me know if this works for you,
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
Is this a literal string "%3D" or are you referring to a single character 0x3d ?
Convert() is a character-by-character conversion; Convert('%3D',':',Arg) is the same as Convert('%',':',Arg) then Convert('3','',Arg) then Convert('D','',Arg) - which is not the effect you intended.
In server jobs and BASIC Transformer stages you could use the Ereplace function, which does perform substring replacement. However I don't believe there's an equivalent in parallel jobs unless you create your own (for example as a buildop or as a parallel routine).
If the substring only occurs once, you could wrap the Convert() function in an If..Then..Else construct. Test for the existence of '%3D' and only apply the Convert() if it's found.
Convert() is a character-by-character conversion; Convert('%3D',':',Arg) is the same as Convert('%',':',Arg) then Convert('3','',Arg) then Convert('D','',Arg) - which is not the effect you intended.
In server jobs and BASIC Transformer stages you could use the Ereplace function, which does perform substring replacement. However I don't believe there's an equivalent in parallel jobs unless you create your own (for example as a buildop or as a parallel routine).
If the substring only occurs once, you could wrap the Convert() function in an If..Then..Else construct. Test for the existence of '%3D' and only apply the Convert() if it's found.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.