Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> RE: Isnumeric question

RE: Isnumeric question

From: Jacques Kilchoer <Jacques.Kilchoer_at_quest.com>
Date: Mon, 22 Sep 2003 17:24:44 -0800
Message-ID: <F001.005D0BBD.20030922172444@fatcity.com>


>-----Original Message-----
>From: ml-errors_at_fatcity.com [mailto:ml-errors_at_fatcity.com]On Behalf Of Teresita Castro
>
>I want to made something like this ina query
>
>select decode( isnumeric(line_comment), to_number(line_comment),0)
>
>how can I do this in Oracle?

First you need to define what "isnumeric" means to you. Does it mean

a) this string only contains ASCII characters 0 through 9
b) this string only contains ASCII characters 0 through 9 with maybe one decimal point (as determined by my NLS settings)'
c) this string only contains ASCII characters 0 through 9 with maybe one decimal point and group separators (as determined by my NLS settings)
d) 'this string contains a valid ORACLE number constant' e.g. -2.3e+10 is a valid number?
e) something else (minus signs, etc.)

If the answer is d), then (from an old idea by Jared Still) create your own function create function is_number (str in varchar2)

   return number
is

   x number ;
begin

   x := to_number (str) ;
   return 1 ;
exception

   when value_error
   then

      return 0 ;
   when others
   then

      raise ;
end ;
/

-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.net
-- 
Author: Jacques Kilchoer
  INET: Jacques.Kilchoer_at_quest.com

Fat City Network Services    -- 858-538-5051 http://www.fatcity.com
San Diego, California        -- Mailing list and web hosting services
---------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).
Received on Mon Sep 22 2003 - 20:24:44 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US