sql语句如下
select * from yhb_h t where t.user_id=56456464
在执行检索数据的时候报如下的错误
java.sql.SQLException: ORA-01722: 无效数字
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:331)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:288)
at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:743)
at oracle.jdbc.driver.T4CStatement.doOall8(T4CStatement.java:207)
at oracle.jdbc.driver.T4CStatement.executeForRows(T4CStatement.java:946)
at oracle.jdbc.driver.OracleStatement.executeMaybeDescribe(OracleStatement.java:1062)
at oracle.jdbc.driver.T4CStatement.executeMaybeDescribe(T4CStatement.java:830)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1132)
at oracle.jdbc.driver.OracleStatement.doScrollExecuteCommon(OracleStatement.java:4055)
at oracle.jdbc.driver.OracleStatement.doScrollStmtExecuteQuery(OracleStatement.java:4195)
at oracle.jdbc.driver.OracleStatement.executeQuery(OracleStatement.java:1279)
at org.apache.tomcat.dbcp.dbcp.DelegatingStatement.executeQuery(DelegatingStatement.java:208)
原因是user_id字段是varchar2类型的,里面正常是都是数字,但是有个别人录入数据的时候里面录了字母。
ORACLE将where t.user_id=56456464解释为where to_number(t.user_id)=56456464
所以进行全表扫描的时候就在将user_id转成数值的时候报错了。
解决的方法是将sql改成
select * from yhb_h t where t.user_id='56456464'