sql - 如何查找导致 ORA-01843 : not a valid month when the data volume is huge? 的记录

标签 sql string oracle datetime oracle11g

我无法将导致无效月份问题的记录清零,想知道是否有更简单的方法来查找导致问题的数据,而不是逐一手动检查所有内容?

编辑:

示例数据(以文本形式出现):

1/17/2019 12:00:00 AM

转换为时间戳:

to_timestamp(tested_date, 'MM/DD/YYYY HH:MI:SS AM')

最佳答案

从 Oracle 12.2 开始,您可以使用 validate_conversion() 来定位无效的日期字符串:

select tested_date
from mytable
where validate_conversion(tested_date as timestamp, 'MM/DD/YYYY HH:MI:SS AM') = 0

来自 the documentation :

VALIDATE_CONVERSION determines whether expr can be converted to the specified data type. If expr can be successfully converted, then this function returns 1; otherwise, this function returns 0.

关于sql - 如何查找导致 ORA-01843 : not a valid month when the data volume is huge? 的记录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60605996/

相关文章:

jquery - 如何编写这个查询以获得正确的结果?

php - 如何在同一字段中的两个值的子句?

php从sql查询中获取大量变量

php - WHERE 附近的 MySql 查询错误

python - 在 Python 中识别某些字符串的最佳方法

objective-c - 像 Objective-C 中的 Python 那样的原始字符串

java - Mac 说 java 已更新但终端不同意

javascript - 在断开连接的状态下运行(移动)网络应用程序?

python - 为什么是 string.join(list) 而不是 list.join(string)?

sql - 是否有用于数据库结构更改的版本控制系统?