惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

量子位
S
Securelist
MyScale Blog
MyScale Blog
Jina AI
Jina AI
罗磊的独立博客
The Cloudflare Blog
美团技术团队
博客园 - 叶小钗
阮一峰的网络日志
阮一峰的网络日志
博客园 - 三生石上(FineUI控件)
月光博客
月光博客
雷峰网
雷峰网
小众软件
小众软件
aimingoo的专栏
aimingoo的专栏
大猫的无限游戏
大猫的无限游戏
博客园 - Franky
博客园 - 聂微东
Y
Y Combinator Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
MongoDB | Blog
MongoDB | Blog
T
Tailwind CSS Blog
Attack and Defense Labs
Attack and Defense Labs
博客园_首页
Latest news
Latest news
Apple Machine Learning Research
Apple Machine Learning Research
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
The Hacker News
The Hacker News
G
GRAHAM CLULEY
Simon Willison's Weblog
Simon Willison's Weblog
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
P
Proofpoint News Feed
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
U
Unit 42
D
Docker
Webroot Blog
Webroot Blog
N
Netflix TechBlog - Medium
T
Tor Project blog
C
Cyber Attacks, Cyber Crime and Cyber Security
L
LINUX DO - 最新话题
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
The Last Watchdog
The Last Watchdog
B
Blog
Recent Announcements
Recent Announcements
GbyAI
GbyAI
Microsoft Azure Blog
Microsoft Azure Blog
Security Latest
Security Latest
V2EX - 技术
V2EX - 技术
N
News | PayPal Newsroom
Microsoft Security Blog
Microsoft Security Blog

博客园 - Render

数据绑定表达与javascript字符串连用 - Render - 博客园 手工删除打印任务 burrow在某些项目使用中报"控件包含代码块(即 <% ... %>),因此无法修改控件集合" - Render httpModules remove does not work in a folder or virtual directory 事件触发型ActiveX放置在网页中的部分思考 Javascript中文字符串处理额外注意事项 - Render - 博客园 Arc Catalog重建索引时报错:ORA-02298: 无法验证 (SDE.A18_FK1) - 未找到父项关键字 (A18_FK1) 指定web.config让httphandler处理某目录及子目录下所有文件 - Render - 博客园 windows命令行里取得年-月-日-时-分-秒的办法 - Render - 博客园 网站复杂信息自动录入处理 css中url的路径含义 ORACLE Transparent Gateway透明网关安装配置小问题 使用OLEDB访问ACCESS的几点经验 ARCIMS Serverlet Connector查询属性,当属性为中文时乱码处理 - Render [转载]ARCIMS 9.2 [ERR0134]错误解决方法 ORACLE 大数据表Update处理 PL/SQL developer的HomeEnd问题(转载) ArcSDE9.0对Oracle初始化参数的要求 在SDE中创建dataset时"Fail to Create, Cann't found spatial referrence entry"错
处理Oralce中非法的日期值
Render · 2008-08-30 · via 博客园 - Render

Oracle中日期列对数据范围有要求,如年份要求为非0,小时要求为非负数,正常情况下,ORACLE是不允许这些数据插入到数据库中存储的。但是一些程序通过一些手段可以向数据库写入这个非法值,已发现的情况有用JAVA程序或Pb程序写入的,通过SQL日期运算也可以写入一些非法日期值。
这些非法日期值一方面是有价值的(比如年月日是对的,只是小时为-1),另一方面,通过ADO.NET是无法直接读取的,甚至转化为字符串也不行,因为一在SQL中使用to_char,转化出来的值就是'0000-00-00'这样的值。
可以使用dump对这些数据分析,如下例子:
select startdate,dump(startdate) from sa.zland where substr(to_char(startdate,'yyyy-MM-dd'),1,4)='0000'
1    1992-12-30    Typ=12 Len=7: 119,192,12,30,0,1,1
2    1992-12-30    Typ=12 Len=7: 119,192,12,30,0,1,1
3    1992-12-30    Typ=12 Len=7: 119,192,12,30,0,1,1
4    1992-12-30    Typ=12 Len=7: 119,192,12,30,0,1,1
5    1992-12-30    Typ=12 Len=7: 119,192,12,30,0,1,1
6    1992-12-30    Typ=12 Len=7: 119,192,12,30,0,1,1

而正常数据是:
select startdate,dump(startdate) from sa.zland where substr(to_char(startdate,'yyyy-MM-dd'),1,4)<>'0000'
1    1900-1-1    Typ=12 Len=7: 119,100,1,1,1,1,1
2    1900-1-1    Typ=12 Len=7: 119,100,1,1,1,1,1
3    1900-1-1    Typ=12 Len=7: 119,100,1,1,1,1,1
4    1900-1-1    Typ=12 Len=7: 119,100,1,1,1,1,1
5    1900-1-1    Typ=12 Len=7: 119,100,1,1,1,1,1
6    1900-1-1    Typ=12 Len=7: 119,100,1,1,1,1,1

,发现这些数据中,小时字段中储存的数据是有问题的,全为0,按ORACLE的定义,即成了-1小时,因此做to_char转化全成了'0000-00-00'。
做这个分析,可以发现异常日期数据中哪个字段出问题,然后对该字段进行修补即可。上例中,小时字段出问题,因此对小时字段修补:
select startdate,dump(startdate+1/24) from sa.zland where substr(to_char(startdate,'yyyy-MM-dd'),1,4)='0000'
全部日期加上1小时,让其为逻辑0点,在正常值范围内。
之后通过to_char转换检查及ado.net读取测试,这些数据全部能正常转换及读取。