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

Thread: Error when doing to_number

  1. #1
    Join Date
    Nov 2000
    Location
    London
    Posts
    83

    Question Error when doing to_number

    Hello. I am trying to right a SQL to take the first letter of a variable using SUBSTR, and convert it to number using TO_NUMBER like this:

    TO_NUMBER(DECODE(SUBSTR((PSADMIN.APPOINTMENTS.WORK_PATTERN,1,1),'H',5,(SUBSTR((PSADMIN.APPOINTMENTS. WORK_PATTERN,1,1)))

    SUBSTR(PSADMIN.APPOINTMENTS.WORK_PATTERN,1,1) returns the characters 1, 2, 3, 4, 5, 6, 7, H

    I know in the above statement where 'H' will return 5, but there may be other alphabets returned as result of doing the SUBSTR in the future, which will cause promlems.

    Is there a way to exclude all alphabetical characters from doing TO_NUMBER, instead of having to use DECODE?

    Thank you for your time and help.
    Regards,
    Fiona

  2. #2
    Join Date
    Nov 2002
    Location
    Geneva Switzerland
    Posts
    3,142
    TRANSLATE should be what you want: http://www.csee.umbc.edu/help/oracle...on.htm#1025232

  3. #3
    Join Date
    Nov 2000
    Location
    London
    Posts
    83
    Will try it - thank you for your help.

    Fiona
    x

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