Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Replacing a value in a fixed position with new value within a string

spalato76Feb 18 2014 — edited Feb 19 2014

Hi All,

I have a column in my table that has a long alphanumeric value, this is a coding system that we use for a datasource in our repository, which I won't really get into.  So the values in the table look like this:

RF104200604059999999990000001366324007SP60ZZ
RF104200604309999999990000001366324012ZZ02ZZ
RF104200604099999999990000001366324023ER20WA
RF104200604279999999990000001366324032CZ28JAPQ
RF104200604259999999990000001366324041PE55BANR
RF104200604259999999990000001366324051NQ59BAGX

What I want to do is retain the existing values with the exception of replacing the 4th and 5th digits which are "04" with "01".  The "04" is always in the same location (position 4 and 5) so I thought about using some combination of substring and instring or the translate function but it doesn't seem to work.  So what I would like is to get the following new values:

RF101200604059999999990000001366324007SP60ZZ
RF101200604309999999990000001366324012ZZ02ZZ
RF101200604099999999990000001366324023ER20WA
RF101200604279999999990000001366324032CZ28JAPQ
RF101200604259999999990000001366324041PE55BANR
RF101200604259999999990000001366324051NQ59BAGX

Any help would be appreciated. I'm using Oracle version 10g.

Thanks,

Ed

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 19 2014
Added on Feb 18 2014
14 comments
1,966 views