Fixed: ORA-01722: invalid number
One of my friends asked me to resolve the oracle “ORA-01722: invalid number” error. He was getting this error while generating reports through an application from oracle 10g database.
I suggested him the solution of this problem because I had also faced same problem few months ago. Before describing solution of this problem, it is necessary to know about the problem.
ORA-01722: invalid number
Root Cause of Error:
You were trying to execute a SQL statement that attempted to convert a string to a number and it failed.
How to resolve Ora-01722: invalid number error?
You can only use numeric fields or character fields that contain numeric data in arithmetic functions and expressions.
You need to check for character strings used in the function or expression. I am showing you one example that will give you complete understanding about this error and how to resolve this issue.
Connect with Oracle Database.
C:\>sqlplus /nolog SQL*Plus: Release 188.8.131.52.0 Production on Sun Jan 26 16:07:24 2014 Copyright (c) 1982, 2010, Oracle. All rights reserved. SQL> conn scott/tiger@xe Connected.
Now issue following commands and see the results:
SQL> select to_number('test') from dual; select to_number('test') from dual * ERROR at line 1: ORA-01722: invalid number SQL> select * from dual where 'test'>100; select * from dual where 'test'>100 * ERROR at line 1: ORA-01722: invalid number
Now look at the below example. In this example one statement is executed correctly but another has an error because that’s not a number.
SQL> select to_number('1000.000') from dual; TO_NUMBER('1000.000') -------------------- 1000 SQL> select to_number('1,000.000') from dual; select to_number('1,000.000') from dual * ERROR at line 1: ORA-01722: invalid number
You Must Read:
I use SEMRush for Keyword Research & Boost Organic Traffic. Do You?
Highly recommended SEM & SEO Tool for overview of Traffic, Keywords, Backlinks and more. You can search your competitors URL to analyze keywords & crush your competition.
Get Free Blogging Tips & Technology updates in your Email !!!
Latest posts by Anil Kumar (see all)
- Top 3 Custom Sidebar WordPress Plugins for Post & Pages - October 17, 2015
- Bluehost Coupon Codes Up To 75% OFF – August 2015 - August 25, 2015
- Make Money Online: $50-$100 Daily with Affiliate Marketing - August 10, 2015