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
srinivenigalla
Participant
Posts: 35 Joined: Thu Aug 11, 2005 5:21 pm
Post
by srinivenigalla » Thu Aug 23, 2007 9:27 am
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
Posts: 992 Joined: Mon Aug 08, 2005 5:08 pm
Location: USA
Post
by gateleys » Thu Aug 23, 2007 9:33 am
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 » Thu Aug 23, 2007 10:24 am
Irespective of the size and the value of the character in first posiition, How can we proceed
chulett
Charter Member
Posts: 43085 Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO
Post
by chulett » Thu Aug 23, 2007 10:56 am
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
Posts: 992 Joined: Mon Aug 08, 2005 5:08 pm
Location: USA
Post
by gateleys » Thu Aug 23, 2007 11:16 am
One of the ways -
Code: Select all
'A':RIGHT[InputString, Len(InputString) - 1]
gateleys
gateleys
Premium Member
Posts: 992 Joined: Mon Aug 08, 2005 5:08 pm
Location: USA
Post
by gateleys » Thu Aug 23, 2007 11:21 am
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 » Thu Aug 23, 2007 11:49 am
I tried the Ereplace function it is returning Value'A' but i want is A001, if the original value is 0001
gateleys
Premium Member
Posts: 992 Joined: Mon Aug 08, 2005 5:08 pm
Location: USA
Post
by gateleys » Thu Aug 23, 2007 1:17 pm
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