Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

TO_NUMBER function on varchar2 column with numbers and strings

30484Oct 15 2002
I need to create a column in a view that converts a varchar2 column data to number. The problem is that some
of the data have strings and some numbers. I get "ORA-01722: invalid number" error when Oracle tries to covert
strings (e.g. 'ABCD') to number. What I need is to get a NULL value if the data is an invalid number.
How can I rewrite the following to get NULL value is a string is invalid number?

select to_number('abcd') numberColumn
from dual

thanx
Alfred

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 12 2002
Added on Oct 15 2002
3 comments
488 views