DBAsupport.com Forums - Powered by vBulletin
Results 1 to 4 of 4

Thread: SELECTIVE UPDATE ??

  1. #1
    Join Date
    Sep 2000
    Location
    Chennai, India
    Posts
    865

    Arrow

    Hi

    In a table, have a column with contents of uniform length 15. This varchar column has to be updated selectively...i.e., 2 characters in the middle have to be replaced with 3 characters. Any idea how to accomplish this ??

    eg.,

    10HN93A1: 1
    10HN93A1: 2
    10HN93A1: 3
    10HN93A1: 4
    10HN93A1: 5
    10HN93A1: 6
    10HN93A1: 7

    In the above, have to replace A1 with A01 to get the following...

    10HN93A01: 1
    10HN93A01: 2
    10HN93A01: 3
    10HN93A01: 4
    10HN93A01: 5
    10HN93A01: 6
    10HN93A01: 7


    So also, the values are A1, B1, C1, C2, C30, etc...

    Thanks.

  2. #2
    Join Date
    Jan 2002
    Location
    Up s**t creek
    Posts
    1,525
    I think you will have to do some string splicing with the SUBSTR function. Or you may be able to use the REPLACE function if you only have one match per row.

    regards
    Jim
    Oracle Certified Professional
    "Build your reputation by helping other people build theirs."

    "Sarcasm may be the lowest form of wit but its still funny"

    Click HERE to vist my website!

  3. #3
    Join Date
    Feb 2000
    Location
    Singapore
    Posts
    1,758
    Assuming all records have same length as you said:

    UPDATE tbl
    SET col = SUBSTR(col,1,7)||'0'||SUBSTR(col, 8,4)
    WHERE your_condition;

    Of course it can be done in many ways.

    Sanjay


  4. #4
    Join Date
    Sep 2000
    Location
    Chennai, India
    Posts
    865
    Thanks. That solved it !!

Posting Permissions

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


Click Here to Expand Forum to Full Width