我有几千行查询,它在很长一段时间内运行良好,并在某个时候开始返回:
ORA-01858: a non-numeric character was found where a numeric was expected
01858. 00000 - "a non-numeric character was found where a numeric was expected"
*Cause: The input data to be converted using a date format model was
incorrect. The input data did not contain a number where a number was
required by the format model.
*Action: Fix the input data or the date format model to make sure the
elements match in number and type. Then retry the operation.
Run Code Online (Sandbox Code Playgroud)
我 99% 确定插入的日期有误。
我的问题是,如果日期格式不正确,是否有一个函数会返回日期或 NULL?
To_date从 12.2 版本开始就可以为您做到这一点。请参阅文档https://docs.oracle.com/en/database/oracle/oracle-database/12.2/sqlrf/TO_DATE.html
select to_date('not a date' default null on conversion error,'yyyymmdd')
from dual;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
686 次 |
| 最近记录: |