栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

PL / SQL开发人员如何获取使插入失败的行?

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

PL / SQL开发人员如何获取使插入失败的行?

在oracle 10gr2中,您可以使用insert命令的log
errors
子句在单独的表中记录错误。这是一个例子:

SQL> create table test_table(  2    id   number primary key,  3    col1 varchar2(7)  4  )  5  ;Table created-- creates a table for logging errors (table name will be prefaced with err$_)SQL> begin dbms_errlog.create_error_log('TEST_TABLE'); end;  2  /PL/SQL procedure successfully completed-- violates primary key constraintSQL> insert into test_table(id, col1)  2  (  select 1, level  3      from dual  4    connect by level <= 3)  5    log errors reject limit unlimited;1 row insertedSQL> commit;SQL> select * from test_table;        ID COL1---------- -------         1 1SQL> select * from err$_test_table;ORA_ERR_NUMBER$ ORA_ERR_MESG$          ORA_ERR_ROWID$  ORA_ERR_OPTYP$ ORA_ERR_TAG$ ID  COL1--------------- ------------------------------------------------------------------------------------------------------------   1 ORA-00001: unique constraint (HR.SYS_C008315) violated  I1     2   1 ORA-00001: unique constraint (HR.SYS_C008315) violated  I1     3


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/634595.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号