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

Thread: Conversion

  1. #1
    Join Date
    Jun 2001
    Posts
    8

    Exclamation

    I have a list of values that I need to convert, and was wondering if their was a substring or replacement funtion, I could use:

    For example:

    Instead of it being P7 "0" the number, it need to be P7"O" the letter, so it should read

    P70:003 should be P7O:00

    helP!!!!!!!!!!!!!!!



  2. #2
    Join Date
    Oct 2000
    Location
    Germany
    Posts
    1,185
    If there are regular patterns, you may be able to use the INSTR or "in string" function.

    You can find the nth occurrance of a string 'ABC' beginning at the pth position of field Field1 with

    INSTR(Field1, 'ABC', p, n)

    You may need to use SUBSTR and concatenate the results. It depends on your situation.

    Good luck.
    David Knight
    OCP DBA 8i, 9i, 10g

  3. #3
    Join Date
    Apr 2001
    Location
    UK
    Posts
    137
    If it's always P7O, you can use replace:

    select replace('P7O:003', 'P70', 'P7O')
    from dual

    If it's just the third character you want to change, you could do:

    select translate(substr('P7O:003',1,3), '0', 'O')||
    substr('P7O:003',4)
    from dual


  4. #4
    Join Date
    Sep 2001
    Location
    Makati, Philippines
    Posts
    857
    this is just an example of what Dave mentioned
    about pattern:
    Here the pattern is there's always ':' between
    alphanumeric(P7O) and all numeric (003).

    Assuming the value of var1 is 'P70:003':

    select replace(substr(var1,1,instr(var1,':',1,1)),'0','O') || substr(var1,instr(var1,':',1,1)+1) "Conversion"
    from dual;

    Conversion
    ----------
    P7O:003
    SQL>


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