oracle to_namber之后报ora-01722:无效数字
2017-03-02 00:15
567 查看
写的sql:
select
to_number(substr(B.年龄, 1, instr(B.年龄, '天') - 1)) as 年龄, A.病人id, A.主页id
from 病案主页 A, 病人信息 B
where A.病人ID = B.病人ID
and A.主页ID = B.主页ID
and to_number(substr(B.年龄, 1, instr(B.年龄, '天') - 1)) < 29
and B.年龄 not like '%岁%'
and B.年龄 not like '%月%'
报错:
加上强制规则,运行通过:
select /*+rule*/ to_number(substr(B.年龄, 1, instr(B.年龄, '天') - 1)) as 年龄, A.病人id, A.主页id from 病案主页 A, 病人信息 B where A.病人ID = B.病人ID and A.主页ID = B.主页ID and to_number(substr(B.年龄, 1, instr(B.年龄, '天') - 1)) < 29 and B.年龄 not like '%岁%' and B.年龄 not like '%月%'
注意:and to_number(substr(B.年龄, 1, instr(B.年龄, '天') - 1)) < 29
不能放在最后一个条件,否则也会报错!
select
to_number(substr(B.年龄, 1, instr(B.年龄, '天') - 1)) as 年龄, A.病人id, A.主页id
from 病案主页 A, 病人信息 B
where A.病人ID = B.病人ID
and A.主页ID = B.主页ID
and to_number(substr(B.年龄, 1, instr(B.年龄, '天') - 1)) < 29
and B.年龄 not like '%岁%'
and B.年龄 not like '%月%'
报错:
加上强制规则,运行通过:
select /*+rule*/ to_number(substr(B.年龄, 1, instr(B.年龄, '天') - 1)) as 年龄, A.病人id, A.主页id from 病案主页 A, 病人信息 B where A.病人ID = B.病人ID and A.主页ID = B.主页ID and to_number(substr(B.年龄, 1, instr(B.年龄, '天') - 1)) < 29 and B.年龄 not like '%岁%' and B.年龄 not like '%月%'
注意:and to_number(substr(B.年龄, 1, instr(B.年龄, '天') - 1)) < 29
不能放在最后一个条件,否则也会报错!
相关文章推荐
- Oracle错误: ORA-01722 无效数字
- oracle排序报错“ORA-01722: 无效数字”处理
- 记一次 oracle ORA-01722: 无效数字 错误排查
- 使用to_number函数,提示ORA-01722无效数字的解决方法
- ORACLE-023:令人烦恼的 ora-01722 无效数字
- 【Oracle】ORA-01722:无效数字(控制文件最后一个字段)
- to_number不了字段-ORA-01722 无效数字
- ORACLE隐式类型转换 ORA-01722: 无效数字
- ORACLE-023:令人烦恼的 ora-01722 无效数字
- oracle ORA-01722:无效数字 记录
- oracle 无效数字ORA-01722:
- oracle ORA-01722无效数字
- Oracle 参数化更新数据时报错:Oracle ORA-01722: 无效数字
- Oracle ORA-01722: 无效数字 处理方法
- Oracle Error:ORA-01465: 无效的十六进制数字
- PL/SQL那点事-->SqlSession operation; SQL []; ORA-01722: 无效数字
- 数据库-ORA-01722:无效数字
- ORA-01861: 文字与格式字符串不匹配,ORA-01722: 无效数字
- PreparedStatement批量向数据库插入数据报了这个异常:java.sql.SQLException:ORA-01722: 无效数字
- java.sql.SQLSyntaxErrorException: ORA-01722: 无效数字