Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: exception free to_number() subsitute?
You could try the function below:
CREATE OR REPLACE FUNCTION chr2nbr (colchr in VARCHAR2)
RETURN NUMBER IS
colnbr NUMBER;
BEGIN
SELECT TO_NUMBER(colchr) INTO colnbr FROM dual; RETURN colnbr;
INVALID_NUMBER is a predefined PL/SQL exception that handles the ORA-01722 error that you will get if you try to convert to number an inappropriate character string.
Hope this helps.
Michael Serbanescu
![]() |
![]() |