25 pts.
 update replace
I'm trying to update a particular text string in a long trxt eg

505400005004GBP23800280000

trying to replace the 10th char 0 with a 1 how can I do this please, thanks



Software/Hardware used:
db2 sql
ASKED: June 25, 2012  5:06 PM
UPDATED: June 26, 2012  8:26 PM

Answer Wiki:
As Phil said, his response will only update when you match the full value. If you want to update the field whenever the 10 position is '0', then change the where clause from (where myString = ‘505400005004GBP23800280000′) to be (where substring(myString,10,1) = '0')
Last Wiki Answer Submitted:  June 25, 2012  6:14 pm  by  CharlieBrowne   33,730 pts.
All Answer Wiki Contributors:  CharlieBrowne   33,730 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

Before you do it as an update do it as a select so you can see how it working
and assuming you only want to update that one value.

Select substring(myString,1,9) || ’1′ || substring(myString,11,50) from myfile
where myString = ’505400005004GBP23800280000′

once that works
Update myfile
set myString =substring(myString,1,9) || ’1′ || substring(myString,11,50);
where myString = ’505400005004GBP23800280000′

Phil

 44,630 pts.

 

Thanks Guys, will give that a go :-)

 25 pts.

 

thanks Guys – that was perfect :-)

 25 pts.

 

Thanks for the feedback

“Silence is the most perfect expression of scorn. ”
George Bernard Shaw

 44,630 pts.