Querying A Table Results In An Apparently Incorrect Error ORA-01722
Last updated on JULY 27, 2017
Applies to:Oracle Database - Enterprise Edition - Version 10.2.0.1 to 220.127.116.11 [Release 10.2 to 11.2]
Oracle Database - Enterprise Edition - Version 18.104.22.168 to 22.214.171.124 [Release 12.1]
Information in this document applies to any platform.
***Checked for relevance on 17-Jul-2016***
When executing a SQL SELECT statement, the operation results in an ORA-1722 error.
The SELECT statement contains a WHERE clause comparing a database column to a numeric literal value, e.g.
In the above example, the column employee_id is a character column (CHAR, VARCHAR or VARCHAR2) and is compared to a literal numeric value.
As a result, the query does not execute and the operation is aborted, even though the table may contain a row with the value '100' in the corresponding column.
The error may be produced in different contexts, as the direct statement issued in SQL*Plus, or a dynamic query in a precompiler program or a java class.
For example, this Java code:
String sqlStatement = 'SELECT last_name FROM employees WHERE employee_id = '+id ;
Sign In with your My Oracle Support account
Don't have a My Oracle Support account? Click to get started
Million Knowledge Articles and hundreds of Community platforms