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

Home -> Community -> Usenet -> c.d.o.tools -> Re: Question? Numeric Functions

Re: Question? Numeric Functions

From: <xmark.powell_at_eds.com.x>
Date: 18 Apr 2001 13:09:23 GMT
Message-ID: <9bk3m3$apc$1@news.netmar.com>

In article <3ADD028B.2B51A249_at_pacbell.net>, Ray Vonhollen <RVONHOLLEN_at_pacbell.net> writes:
>Is there any good numeric function available that can check to see if a
>varchar2 or char column contains a pure numeric number? Preferably, a
>function that can be checked by an If Statement without generating a
>PLS-00382 error. It would only execute the preceding Block if statements
>and no execute upon failure.
>
>As an example a column containing the values '102-1' would generate an
>error in using the TO_NUMBER() function, but a column containing the
>values '102.1' would not.
>
>Any help would be greatly appreciated.
>
>Ray-

Ray, use exception logic around the to_number after using rtrim and ltrim to remove any excess characters from the column. You can use instr and substr to remove $ and commas etc...

begin
 v_fld := to_number(variable);
exception
 when others then non-numeric-logc
end;

You will probably want to make the edit routine a procedure within your code so that you can call it from right before you need to use it and can include any trimming, substringing etc... that you need to perform. Your procedure would probably look something like
 (v_success_indicator, v_char_value, v_number)

I hope this helps.

Received on Wed Apr 18 2001 - 08:09:23 CDT

Original text of this message

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