update replace

25 pts.
Tags:
AS/400 DB2
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

Answer Wiki

Thanks. We'll let you know when a new response is added.

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’)

Discuss This Question: 4  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • philpl1jb
    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
    51,355 pointsBadges:
    report
  • Randybc
    Thanks Guys, will give that a go :-)
    25 pointsBadges:
    report
  • Randybc
    thanks Guys - that was perfect :-)
    25 pointsBadges:
    report
  • philpl1jb
    Thanks for the feedback "Silence is the most perfect expression of scorn. " George Bernard Shaw
    51,355 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following