Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2004
    Location
    India
    Posts
    191

    Unanswered: Replace character from string

    Hi,

    How to replace specific character from a string.
    I have '100001'
    i want to replace 2nd chracter '0' with '1' .i.e.
    Result output would be

    '110001'

    Can we do it by using oracle function i.e Replace and transalate

    Thanks
    Paginit
    Pagnint
    (No need to search web before posting new question)

  2. #2
    Join Date
    Sep 2002
    Location
    UK
    Posts
    5,171
    Provided Answers: 1

    Re: Replace character from string

    You could change this specific string using REPLACE:

    REPLACE('100001','10','11')

    But in general, that would not work - e.g. it would not work for the string '100010', because it would change the 2nd and 6th characters both to 1.

    To specificy a particular character position for change you must use SUBSTR:

    SUBSTR(string,1,1) || '1' || SUBSTR(string, 3)

    This takes the first character, appends a '1', and then appends the rest of the string from position 3 (omitting position 2).

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •