我有一个带有where子句的函数select语句,在where子句中有一个类似的语句……
to_date(camp.start_date, ‘MM/DD/YYYY’) >= to_date(:from_date,
‘YYYY-MM-DD HH24:MI:SS’)
但是,如果camp.start_date为NULL或没有行,那么它会抛出异常 –
ORA-01858: a non-numeric character was found where a numeric was
expected
camp.start_date实际上是一个我需要转换为日期的VARCHAR2,(是的,我知道它可能应该是一个日期字段,但我没有选项可以更改它).
我试过这样的事……
to_date(NVL(camp.start_date,SYSDATE), 'MM/DD/YYYY') >=
to_date(:from_date, 'YYYY-MM-DD HH24:MI:SS')
哪个仍然给我一个错误.也试过了
where camp.start_date is not null and to_date(camp.start_date,
‘MM/DD/YYYY’) >= to_date(:from_date, ‘YYYY-MM-DD HH24:MI:SS’)
同样的问题.围绕这个最好的方法是什么?基本上,当camp.start_date不是有效日期时,to_date会爆炸并抛出错误.