oracle 获取“ORA-01722:invalid number”在外部查询中尝试查找数字时出错,该数字为null或小于某个数字

icnyk63a  于 2023-06-05  发布在  Oracle
关注(0)|答案(1)|浏览(166)

我试图找到“id_case”(这里id_case是数字)为空或小于1的值,但得到“ORA-01722:invalid number“,查询如下:

SELECT v.id, v.id_case_p, v.id_case FROM (
SELECT p.id, to_number(replace(p.description,'xyy_','')) as id_case_p, c.id as id_case 
FROM t_processes p left join t_cases c on to_number(replace(p.description,'xyz_','')) = c.id 
where p.active ='Y' and p.id_process_step < 10 
)v 
WHERE v.id_case < 1
;

我也试过下面的方法,但还是出现了同样的错误。

SELECT v.id, v.id_case_p, v.id_case FROM (
    SELECT p.id, to_number(replace(p.description,'xyy_','')) as id_case_p, c.id as id_case 
    FROM t_processes p left join t_cases c on to_number(replace(p.description,'xyz_','')) = c.id 
    where p.active ='Y' and p.id_process_step < 10 
    )v 
    WHERE v.id_case is null
    ;

任何线索都将不胜感激。

wz1wpwve

wz1wpwve1#

请运行:

SELECT p.id, to_number(replace(p.description,'xyy_','') default null on 
    conversion error) as id_case_p, c.id as id_case 
  FROM t_processes p 
  left join MD2.t_cases c on to_number(replace(p.description,'xyz_','') default null on conversion error) = c.id 
  where p.active ='Y' and p.id_process_step < 10 ;

看看你能得到什么。
还运行:

SELECT p.* 
 FROM t_processes p
 where  to_number(replace(p.description,'xyy_','') default null on 
    conversion error) is null

看看这会带来什么。

相关问题