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: Reardon, Bruce (CALBBAY) <Bruce.Reardon_at_comalco.riotinto.com.au>
Date: Mon, 22 Sep 2003 17:14:47 -0800
Message-ID: <F001.005D0BBC.20030922171447@fatcity.com>


Previously posted by Jared is the is_number function below:

You could avoid the decode statement and have the exception return zero for a non-numeric parameter - of course you'd want to rename the function to something more meaningful in that case.

"
-----Original Message-----
Sent: Saturday, 1 February 2003 8:05 AM
To: Multiple recipients of list ORACLE-L

create or replace function is_number( chk_data_in varchar2 ) return boolean
is

        dummy number(38,4);
begin

        dummy := to_number(chk_data_in);
        return true;

exception
when value_error then

        return false;
when others then

        raise;
end;
/

show errors function is_number

declare

        v_test varchar2(10) := '1E';
begin

        if is_number(v_test) then
                dbms_output.put_line(v_test || ' is a number');
        else
                dbms_output.put_line(v_test || ' is NOT a number');
        end if;

end;
/
"

HTH,
Bruce Reardon

-----Original Message-----
Sent: Tuesday, 23 September 2003 11:00 AM

On 2003.09.22 20:15, Teresita Castro wrote:
> Hi!!
> 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?
>

my $line_comment;
my $sth=$dbh->prepare("Select line_comment from...."); $sth->execute();
$sth->bind_col(1,\$line_comment);
while ($sth->fetchrow_array() {
  if ( $line_comment =~ /^[0-9]+/) {......} }

-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.net
-- 
Author: Reardon, Bruce (CALBBAY)
  INET: Bruce.Reardon_at_comalco.riotinto.com.au

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:14:47 CDT

Original text of this message

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