Replacing & character

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
Diya
Participant
Posts: 38
Joined: Fri Feb 17, 2006 7:02 am

Replacing & character

Post by Diya »

Hi all,

My Job generate xml files from csv files.
As xml file will not recognize '&' char ,I need to repalce it with '&'

Now I am using change Function which is there in Basic Transformer.

But this is causing lot of troubles while running .The processs are getting locked very frequently.

Is there any function in Normal Transformer to replace this '&' character.

Thanks.
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

What function are you using?
Try using EREPLACE or just replace it using an " IF THEN" statement.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
Diya
Participant
Posts: 38
Joined: Fri Feb 17, 2006 7:02 am

Post by Diya »

I am using the CHANGE function now.Could you please tell me the syntax for EReplace in this case to replce an '&' character
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

The Change and Ereplace functions are the same (except when
evaluating an emptyr string).

You might write a normal Server job to read you source file, parse it and write it back out to another sequential file, which your PX job then reads. It will make maintenance and debugging easier and might even make it faster if your XML files are small (due to the overhead involved in starting PX jobs).
Diya
Participant
Posts: 38
Joined: Fri Feb 17, 2006 7:02 am

Post by Diya »

I have to use a parallel job as I have to generate multiple xml files in a single job which includes Joiners also..
I just want to know the Function which a Normal Transformer supports this Replacing instead of Using a Basic Transformer to implement this replacement
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Diya, there is no equivalent to the server ereplace function in a PX transform stage. You can find an occurrence with INDEX or replace one character with one other character using CONVERT but for more than that you would need to write your own short c++ routine.
anntaylor
Participant
Posts: 24
Joined: Tue May 10, 2005 5:17 pm

Post by anntaylor »

I use the below to replace a CR in a comment field. You can do something similar

Convert(char(10), ". ",AOStyleComment.RemarkType)
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Anna,

no, the CONVERT function is useless in this case since the poster wants to convert one character into a sequence of 4 characters.

CONVERT('&','&',In.Column) will not do any changes at all to the value, It will replace "&" with "&" and the rest of the resulting to-conversion string won't even be used.
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Why not just simple add an if then statement as i meantioned.

If Link.Column='&' then '&AMP' else.... whatever you want to do.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

The original statement of the problem specified that a BASIC Transformer stage was being used, where both Change() and Ereplace() might legally be used. This is not the problem.

The problem is that something, somewhere, is locking.

Can you please explain exactly what you mean by "the processes are getting locked" and what symptom that you observe leads to this particular diagnosis?

The Change() function can not cause any kind of locking.

However, the interface between a parallel job and a BASIC Transformer stage may - I repeat, may - be the culprit. We need to eliminate all other possibilities before we can be any more certain than that.
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