批量插入的错误如何跟踪?

[复制链接]
查看11 | 回复9 | 2007-10-20 08:38:44 | 显示全部楼层 |阅读模式
我使用的代码是
insert into T select ....这种形式。但是插入过程发生了错误。从Exception来看,是因为有数据的日期格式有问题导致的。
但是我想知道具体是哪行数据导致了这个错误。请问这个怎么跟踪到具体的行呢?
回复

使用道具 举报

千问 | 2007-10-20 08:38:44 | 显示全部楼层
book
回复

使用道具 举报

千问 | 2007-10-20 08:38:44 | 显示全部楼层
关注
回复

使用道具 举报

千问 | 2007-10-20 08:38:44 | 显示全部楼层
把它改成一行一行插入
回复

使用道具 举报

千问 | 2007-10-20 08:38:44 | 显示全部楼层
http://download.oracle.com/docs/ ... s_9014.htm#BCEGDJDJ
Inserting Into a Table with Error Logging: Example
The following statements create a raises table in the sample schema hr, create an error logging table using the DBMS_ERRLOG package, and populate the raises table with data from the employees table. One of the inserts violates the check constraint on raises, and that row can be seen in errlog. If more than ten errors had occurred, then the statement would have aborted, rolling back any insertions made:
CREATE TABLE raises (emp_id NUMBER, sal NUMBER
CONSTRAINT check_sal CHECK(sal > 8000));
EXECUTE DBMS_ERRLOG.CREATE_ERROR_LOG('raises', 'errlog');
INSERT INTO raises
SELECT employee_id, salary*1.1 FROM employees
WHERE commission_pct > .2
LOG ERRORS INTO errlog ('my_bad') REJECT LIMIT 10;
SELECT ORA_ERR_MESG$, ORA_ERR_TAG$, emp_id, sal FROM errlog;
ORA_ERR_MESG$
ORA_ERR_TAG$ EMP_ID SAL
--------------------------- -------------------- ------ -------
ORA-02290: check constraint my_bad
1617700
(HR.SYS_C004266) violated
回复

使用道具 举报

千问 | 2007-10-20 08:38:44 | 显示全部楼层
原帖由 newkid 于 2009-12-27 22:50 发表
http://download.oracle.com/docs/ ... s_9014.htm#BCEGDJDJ
Inserting Into a Table with Error Logging: Example
The following statements create a raises table in the sample schema hr, create an error logging table using the DBMS_ERRLOG package, and populate the raises table with data from the employees table. One of the inserts violates the check constraint on raises, and that row can be seen in errlog. If more than ten errors had occurred, then the statement would have aborted, rolling back any insertions made:
CREATE TABLE raises (emp_id NUMBER, sal NUMBER
CONSTRAINT check_sal CHECK(sal > 8000));
EXECUTE DBMS_ERRLOG.CREATE_ERROR_LOG('raises', 'errlog');
INSERT INTO raises
SELECT employee_id, salary*1.1 FROM employees
WHERE commission_pct > .2
LOG ERRORS INTO errlog ('my_bad') REJECT LIMIT 10;
SELECT ORA_ERR_MESG$, ORA_ERR_TAG$, emp_id, sal FROM errlog;
ORA_ERR_MESG$
ORA_ERR_TAG$ EMP_ID SAL
--------------------------- -------------------- ------ -------
ORA-02290: check constraint my_bad
1617700
(HR.SYS_C004266) violated

学习
回复

使用道具 举报

千问 | 2007-10-20 08:38:44 | 显示全部楼层
spool
回复

使用道具 举报

千问 | 2007-10-20 08:38:44 | 显示全部楼层
学习~
回复

使用道具 举报

千问 | 2007-10-20 08:38:44 | 显示全部楼层
10G及以上版本可以用newid的那种方法。
回复

使用道具 举报

千问 | 2007-10-20 08:38:44 | 显示全部楼层
原帖由 newkid 于 2009-12-27 22:50 发表
http://download.oracle.com/docs/ ... s_9014.htm#BCEGDJDJ
Inserting Into a Table with Error Logging: Example
The following statements create a raises table in the sample schema hr, create an error logging table using the DBMS_ERRLOG package, and populate the raises table with data from the employees table. One of the inserts violates the check constraint on raises, and that row can be seen in errlog. If more than ten errors had occurred, then the statement would have aborted, rolling back any insertions made:
CREATE TABLE raises (emp_id NUMBER, sal NUMBER
CONSTRAINT check_sal CHECK(sal > 8000));
EXECUTE DBMS_ERRLOG.CREATE_ERROR_LOG('raises', 'errlog');
INSERT INTO raises
SELECT employee_id, salary*1.1 FROM employees
WHERE commission_pct > .2
LOG ERRORS INTO errlog ('my_bad') REJECT LIMIT 10;
SELECT ORA_ERR_MESG$, ORA_ERR_TAG$, emp_id, sal FROM errlog;
ORA_ERR_MESG$
ORA_ERR_TAG$ EMP_ID SAL
--------------------------- -------------------- ------ -------
ORA-02290: check constraint my_bad
1617700
(HR.SYS_C004266) violated

非常感谢!我去试试
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行