Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: function for translating string to number
Mark D Powell schrieb:
>
> On Jan 23, 8:34 am, "Eitan M" <no_spam_please_at_nospam_please.com>
> wrote:
>> Hello, >> >> I want to translate string to number, >> but if the string is not a number, >> I want that the result will be some default (can be zero). >> >> to_number('a') run an exception, >> but I am looking for a function that return a default number, >> whether the string doesn't represent a numeric value, please. >> >> Thanks :)
Or (on 10g) you can use regexp_ functions for that:
SQL> with t as (
2 select '1' a_number from dual 3 union all 4 select 'X' from dual 5 union all 6 select '2x' from dual 7 union all 8 select '-25' from dual 9 union all 10 select '-' from dual
THE_NUMBER
1 0 0 -25 0
Best regards
Maxim Received on Tue Jan 23 2007 - 13:04:27 CST
![]() |
![]() |