问题描述
我正在将数据从旧系统迁移到我们的新应用程序(在 Oracle 数据库 10gR2 上运行).作为迁移的一部分,我正在编写一个脚本,该脚本将数据插入到应用程序使用的表中.
I'm working on migration of data from a legacy system into our new app(running on Oracle Database, 10gR2). As part of the migration, I'm working on a script which inserts the data into tables that are used by the app.
导入的数据行数达到数千,源数据不干净(NOT NULL 列中出现意外的空值等).所以在通过脚本插入数据的时候,每当发生这样的异常时,脚本会突然结束,整个事务被回滚.
The number of rows of data that are imported runs into thousands, and the source data is not clean (unexpected nulls in NOT NULL columns, etc). So while inserting data through the scripts, whenever such an exception occurs, the script ends abruptly, and the whole transaction is rolled back.
有没有办法可以继续插入行干净的数据?使用 NVL() 或 COALESCE() 不是一种选择,因为我想记录导致错误的行,以便可以在下一次通过时更正数据.
Is there a way, by which I can continue inserts of data for which the rows are clean?
Using NVL() or COALESCE() is not an option, as I'd like to log the rows causing the errors so that the data can be corrected for the next pass.
我当前的过程有一个异常处理程序,我正在记录导致错误的第一行.插入是否可以继续而不终止,因为现在在第一个处理的异常处,过程终止执行.
My current procedure has an exception handler, I am logging the first row which causes the error. Would it be possible for inserts to continue without termination, because right now on the first handled exception, the procedure terminates execution.
推荐答案
使用 PLSQL,您可以在其自己的事务中执行每个插入(在每个之后提交),并使用持续运行的异常处理程序记录或忽略错误.
Using PLSQL you can perform each insert in its own transaction (COMMIT after each) and log or ignore errors with an exception handler that keeps going.
这篇关于引发异常时在 Oracle 中继续插入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!


大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)