Replacing multiple Strings in a Field without Routines

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
Nagasudheerkumar
Premium Member
Premium Member
Posts: 55
Joined: Tue Apr 24, 2007 1:26 am

Replacing multiple Strings in a Field without Routines

Post by Nagasudheerkumar »

My Job Design:

Code: Select all

Table(A)-->Transformer-->Table(B)
Table A have column NIVA and its values are fsdidkg,kdikkd,joejut and i need to replace those values with G,F,F.

fsdidkg = G
kdikkd = F
joejut = F

I have used ereplace and convert functions but i could able to change only G or F, If i am using more ereplace funtions it is giving me 0 in the output.

my code is ereplace('NIVA','fsdidkg','G') Or ereplace('NIVA','kdikkd','G') and i am getting 0 in the output.

I tried searching in the Forum about this issue but couldn't found any.

Can anybody let me know how to solve this problem?
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Ereplace() is not a Boolean function. It returns the new string. Therefore you need nested Ereplace() functions or, perhaps, cascaded stage variables.

Code: Select all

Ereplace(Ereplace(Ereplace(InLink.NIVA, "joejut", "F", -1, 0), "kdikkd", "F", -1, 0), "fsdidkg", "G", -1, 0)

Code: Select all

sv1 <-- Ereplace(InLink.NIVA, "joejut", "F", -1, 0)
sv2 <-- Ereplace(sv1, "kdikkd", "F", -1, 0)
sv3 <-- Ereplace(sv2, "fsdidkg", "G", -1, 0)
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Nagasudheerkumar
Premium Member
Premium Member
Posts: 55
Joined: Tue Apr 24, 2007 1:26 am

Post by Nagasudheerkumar »

Thanks Ray.. Its working now with the first approach..
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

It would work with either approach! :wink:
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