Adding a Character in the transformation

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
srinivenigalla
Participant
Posts: 35
Joined: Thu Aug 11, 2005 5:21 pm

Adding a Character in the transformation

Post by srinivenigalla »

I get a value in Char "00000012" but i need to replace the first character of the value with 'A'.
What is the best way of doing it.
gateleys
Premium Member
Premium Member
Posts: 992
Joined: Mon Aug 08, 2005 5:08 pm
Location: USA

Re: Adding a Character in the transformation

Post by gateleys »

srinivenigalla wrote:I get a value in Char "00000012" but i need to replace the first character of the value with 'A'.
What is the best way of doing it.

1. Is the length always the same?
2. Is the first character always 0?
gateleys
srinivenigalla
Participant
Posts: 35
Joined: Thu Aug 11, 2005 5:21 pm

Post by srinivenigalla »

Irespective of the size and the value of the character in first posiition, How can we proceed
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Substring off the "2nd thru len()" characters and concatenate your new value onto the front it that.
-craig

"You can never have too many knives" -- Logan Nine Fingers
gateleys
Premium Member
Premium Member
Posts: 992
Joined: Mon Aug 08, 2005 5:08 pm
Location: USA

Post by gateleys »

One of the ways -

Code: Select all

'A':RIGHT[InputString, Len(InputString) - 1]
gateleys
gateleys
Premium Member
Premium Member
Posts: 992
Joined: Mon Aug 08, 2005 5:08 pm
Location: USA

Post by gateleys »

Another way -

Code: Select all

Ereplace(InputString, InputString[1,1], 'A', 1, 1)
gateleys
srinivenigalla
Participant
Posts: 35
Joined: Thu Aug 11, 2005 5:21 pm

Post by srinivenigalla »

I tried the Ereplace function it is returning Value'A' but i want is A001, if the original value is 0001
gateleys
Premium Member
Premium Member
Posts: 992
Joined: Mon Aug 08, 2005 5:08 pm
Location: USA

Post by gateleys »

srinivenigalla wrote:I tried the Ereplace function it is returning Value'A' but i want is A001, if the original value is 0001
I just tried it, and the input '0001' does return 'A001' with the Ereplace function I provided. Please check that you have used it correctly, that is, as I have specified above. You may have skipped the last 2 arguments.
gateleys
Post Reply