无效号码,如果没有无效号码

时间:2018-11-19 20:56:34

标签: numbers substring oracle-sqldeveloper

Oracle抛出错误时有问题

  

ORA-01722:无效的号码   01722. 00000-“无效编号”   *原因:指定的号码无效。   *操作:指定一个有效的数字。

除已排除的一些异常情况外,所有位置均遵循相同的规则。

下面是示例输出:

enter image description here

A列:该行必须小于39

B列:身高必须小于17

Location_23_23是小岛

某些位置的设计不同,因此我在位置6处添加了“-”检查以消除这些错误。例如(C0S1-0101)

ive已导出数据,未发现异常,但是在结果中滚动时会出现错误。

下面的代码:

select location_id,to_number(ltrim(rtrim(substr(location_id,7,2)))) asa,to_number(ltrim(rtrim(substr(location_id,9,2)))) as b,to_number(ltrim(rtrim(substr(location_id,4,2)))) as Location_23_23
from location 
where location_id like '%C0S%'
and location_id not in ('C0SKRUSAGE','C0SKYUSAGE','C0SRBUSAGE') 
and to_number(ltrim(rtrim(substr(location_id,7,2)))) < 39  
and current_volume = 0  
and to_number(ltrim(rtrim(substr(location_id,9,2)))) < 17
and to_number(ltrim(rtrim(substr(location_id,4,2)))) between 23 and 23
and substr(location_id,6,1) = '-'

1 个答案:

答案 0 :(得分:0)

这玩了几个小时后终于解决了我的问题!

select location_id as Location_id
from location 
where location_id like '%C0S%'
and location_id not in ('C0SKRUSAGE','C0SKYUSAGE','C0SRBUSAGE') 
and ltrim(rtrim(substr(location_id,7,2))) < '48' 
and current_volume = 0 
and ltrim(rtrim(substr(location_id,9,2))) < '15'
and ltrim(rtrim(substr(location_id,4,2))) between '65' and '86'
and substr(location_id,6,1) = '-'

删除TO_NUMBER并在数字周围添加“#”!