Problem using Convert in Transformer

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

kittu.raja
Premium Member
Premium Member
Posts: 175
Joined: Tue Oct 14, 2008 1:48 pm

Problem using Convert in Transformer

Post by kittu.raja »

HI,

I have a job which looks like

seqfile -----> transformer ---------> seqfile

The requirement is if the data is "]]CDATA]" then they have to change it to
"![CDATA[". when I tried to use convert I am getting "!!CDATA!". can anybody help me out.

Thanks,

**Note - Subject changed to be more descriptive - Content Editor**
Rajesh Kumar
betterthanever
Participant
Posts: 152
Joined: Tue Jan 13, 2009 8:59 am

Re: Transformer

Post by betterthanever »

convert function does not work the way you are understanding...

it does not look for a string and replace it with the string you give...

but looks for the character by character
meaning for ex:

if you say convert('ab','cd',link.col)..
it replaces 'a' with 'c' and 'b' with 'd'...
kittu.raja
Premium Member
Premium Member
Posts: 175
Joined: Tue Oct 14, 2008 1:48 pm

Re: Transformer

Post by kittu.raja »

[quote="betterthanever"]convert function does not work the way you are understanding...


Can you tell me how can I achive my target data?
Rajesh Kumar
betterthanever
Participant
Posts: 152
Joined: Tue Jan 13, 2009 8:59 am

Re: Transformer

Post by betterthanever »

search the forum...you will get lot of info on this
kittu.raja
Premium Member
Premium Member
Posts: 175
Joined: Tue Oct 14, 2008 1:48 pm

Re: Transformer

Post by kittu.raja »

betterthanever wrote:search the forum...you will get lot of info on this
I searched the form by replace a string, but I did not get the right one.
Rajesh Kumar
betterthanever
Participant
Posts: 152
Joined: Tue Jan 13, 2009 8:59 am

Re: Transformer

Post by betterthanever »

[quote="kittu.raja"][quote="betterthanever"]search the forum...you will get lot of info on this[/quote]

I searched the form by replace a string, but I did not get the right one.[/quote]

check this

http://dsxchange.com/viewtopic.php?t=10 ... f69dc268a1
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

You need something more complex, though a Convert() function is certainly involved. First you need a conditional expression, because the data won't always be "]]CDATA]". Then, assuming that this is the entire contents (rather than partial), you need to replace the first character with "!" and convert the remaining "]" characters to "[".

Hence

Code: Select all

If InLink.TheField = "]]CDATA]" Then "!" : Convert("]", "[", InLink.TheField[2, Len(InLink.TheField) - 1] Else InLink.TheField
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
mk_ds09
Participant
Posts: 72
Joined: Sun Jan 25, 2009 4:50 pm
Location: Pune

Post by mk_ds09 »

Can you give more details about your requirements ?

Is everytime data is coming like '"]]CDATA]"' and you have to convert it to the "![CDATA[" ?

Or it is only the first occurance of the ] needs to be converted to the !.

Then you can just use convert on the rest of the string using convert and use concatanation for the first charater....
-----------------------------------
Regards
MK

What would you attempt to do if you knew you could not fail?

-----------------------------------
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

If you had premium membership you would be able to read the complete solution in my earlier post.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
kittu.raja
Premium Member
Premium Member
Posts: 175
Joined: Tue Oct 14, 2008 1:48 pm

Post by kittu.raja »

ray.wurlod wrote:If you had premium membership you would be able to read the complete solution in my earlier post.
K right now I am buying the premium membership
Rajesh Kumar
kittu.raja
Premium Member
Premium Member
Posts: 175
Joined: Tue Oct 14, 2008 1:48 pm

Post by kittu.raja »

mk_ds09 wrote:Can you give more details about your requirements ?

Is everytime data is coming like '"]]CDATA]"' and you have to convert it to the "![CDATA[" ?

Or it is only the first occurance of the ] needs to be converted to the !.

Then you can just use convert on the rest of the string using convert and use concatanation for the first charater....
Everytime I have to convert it and convert is not working on string replace
Rajesh Kumar
kittu.raja
Premium Member
Premium Member
Posts: 175
Joined: Tue Oct 14, 2008 1:48 pm

Post by kittu.raja »

ray.wurlod wrote:If you had premium membership you would be able to read the complete solution in my earlier post.
I bought the premium membership, but its still showing me premium content. Can you help me out.
Rajesh Kumar
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

No, only the membership director can. You are not yet showing up as a premium member.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
kittu.raja
Premium Member
Premium Member
Posts: 175
Joined: Tue Oct 14, 2008 1:48 pm

Post by kittu.raja »

ray.wurlod wrote:No, only the membership director can. You are not yet showing up as a premium member. ...
I bought the membership today and shipping is downloadable. I did not get any downloadbale file and still its showing me participant
Rajesh Kumar
kittu.raja
Premium Member
Premium Member
Posts: 175
Joined: Tue Oct 14, 2008 1:48 pm

Post by kittu.raja »

ray.wurlod wrote:You need something more complex, though a Convert() function is certainly involved. First you need a conditional expression, because the data won't always be "]]CDATA]". Then, assuming that this is ...
the data is not just "] CDATA". it contains a big staement in which CDATA is part of it. So I cannot use If then Else.
Rajesh Kumar
Post Reply