Home  >  Article  >  Database  >  Oracle ORA-01722 错误解决

Oracle ORA-01722 错误解决

WBOY
WBOYOriginal
2016-06-07 17:33:392613browse

对于ldquo;ORA-01722:无效数字错误rdquo; 以前总遇到,今天又遇到了!

对于“ORA-01722:无效数字错误” 以前总遇到,今天又遇到了!

产生的情况:

查出的字段中,,需要转化为number型的时候,比较常见。

例如 ,创建物化视图时,如果有某一个列需要转成number的时候,就很常见,

create materialized view mv_test as

select name,

to_number(zd1) zd1, --  @1

cast(zd2 as number) zd2  --@2

from abc

where to_number(zd3)=10 ; --@3

@1 为 select 中的 to_number 时出现,

@ 2为 select 中的cast 函数时出现,

@3 为where条件中,使用to_number时出现。

注意:@1 与@2中是创建物化视图或者select 创建表或者 只是查询时并全部展开时会出现。

解决方法:

1)nvl空转化为数字 , 如,to_number(nvl(z1,0)) ,cast(nvl(zd2) as number)

2)  在1方法无法解决的时候,就是存在无法转化为number的值存在,就是说该字段中存在其他类型的数据,比如字符,

这个时候,转化为varchar或varchar2或保持原数据类型, 如,cast(zd1 as varchar2(32))

相关阅读:

ORA-01172、ORA-01151错误处理

ORA-00600 [2662]错误解决

ORA-01078 和 LRM-00109 报错解决方法

ORA-00471 处理方法笔记

ORA-00314,redolog 损坏,或丢失处理方法

ORA-00257 归档日志过大导致无法存储的解决办法

linux

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn