Monday, January 5, 2009

ORA-01722: invalid number

Error Description:
-----------------------------------

Any procedure, function or statements failed with ORA-01722. Like,
SQL> select * from a where a='d';
select * from a where a='d'
*
ERROR at line 1:
ORA-01722: invalid number

Cause of The Problem:
-------------------------------------------

There error comes as either implicitly or explicitly the attempted conversion of a character string to a number failed because the character string was not a valid numeric literal. Only numeric fields or character fields containing numeric data may be used in arithmetic functions or expressions. Only numeric fields may be added to or subtracted from dates.

Oracle tried to convert a value to a number and found an illegal value.

Solution of The Problem:
-------------------------------------

Check the SQL statement that raises the error. Check the table definitions. Fix the character strings in the function or expression. Check that they contain only numbers, a sign, a decimal point, and the character "E" or "e" and retry the operation.

Like
SQL> select * from a where a='d';
select * from a where a='d'
*
ERROR at line 1:
ORA-01722: invalid number

SQL> desc a;
Name Null? Type
----------------------------------------- -------- ----------------------------
A NUMBER

As a is number data type and 'd' can't be converted to number , hence error arises. So use numeric value instead of 'd'.

SQL> select * from a where a=1;

A
----------
1

No comments:

Post a Comment