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: function to get only numbers

Re: function to get only numbers

From: Mark D Powell <mark.powell_at_eds.com>
Date: 5 Jul 2001 06:19:10 -0700
Message-ID: <178d2795.0107050519.3a2a9f75@posting.google.com>

"Philippe Makowski" <makowski.philippe_at_wanadoo.fr> wrote in message news:<9i05pr$i8b$1_at_wanadoo.fr>...
> why this function does not compile ?
>
>
> CREATE OR REPLACE FUNCTION char2num (charnum in varchar2) RETURN number IS
> i number;
> digits number;
> current_digit char(1);
> parsechar varchar2;
> BEGIN
> parsechar :='';
> digits := length(charnum);
> for i in 1..digits loop
> current_digit := SUBSTR(charnum, i, 1);
> if current_digit in ('0','1','2','3','4','5','6','7','8','9') then
> parsechar := parsechar || current_digit;
> end loop;
> return to_number(parsechar);
> END char2num;

The error message was reasonably clear. First, you are missing the 'end if' to your one if statement. Once you fix that you will get a whole slew of errors that trace back to line 5 where you failed to assign a maximum length to parsechar. After that it compiled for me.

Received on Thu Jul 05 2001 - 08:19:10 CDT

Original text of this message

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