| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> c.d.o.server -> Re: Gotta Be Simple PL/SQL
might be a more elegant way to do this.. wrote this func 4-5 years
ago... don't guarantee it'll work.. but..
SQL> select char_to_num ('bill is 35 today') from dual;
CHAR_TO_NUM('BILLIS35TODAY')
that'll be 500 rupees
FUNCTION CHAR_TO_NUM (p_string IN VARCHAR2)
RETURN VARCHAR2
AS
v_string varchar2(200); v_ascii number(3); v_saved_string varchar2(20);
v_ascii:=ASCII(v_string); /*look at the firstletter*/
a number*/
dbms_output.put_line('INSIDE IF: '||v_saved_string);
v_string:=SUBSTR(v_string, 2);
ELSE
BEGIN
v_saved_string:=v_saved_string||SUBSTR(v_string,1,1);
v_string:=SUBSTR(v_string, 2);
dbms_output.put_line('INSIDE ELSE: '||v_saved_string);
END;
>Hi all
>
> OK, I feel embarresed.
>
> What is the simplest way to pick a number out of a string, i.e. 'Bill is
>35 today' should return 35. I'm thinking some combination of substr and
>instr.
>
> Any thoughts? Any nice thoughts, at least?
>
>Joe
>
>
.......
We use Oracle 8.1.7.4 on Solaris 2.7 boxes
remove NSPAM to email
Received on Fri Apr 30 2004 - 15:43:47 CDT
![]() |
![]() |