例如,我尝试在 oracle sql 表中插入 9 列。
表 ACCOUNTREQUEST:7 行已成功加载。 2 由于数据错误而未加载行。
我想创建一个 echo.txt 或 .log 来计算错误和错误名称。我将此作为我的控制数据
LOAD DATA
INFILE 'csv_accountrequest.csv'
BADFILE 'bad_accountrequest.bad'
APPEND INTO TABLE AccountRequest
FIELDS TERMINATED BY "," TRAILING NULLCOLS
(requestid "request_id_interval.nextval", branch, account_type, title, firstname, lastname, Birthday Date "dd/mm/yyyy", workphone, homephone, address, state, zip, email,status)
并将其作为我的 csv
1,manila,SAVINGS,MR,Alpha,Bravo,01/02/2000,21313,213,kor,north,3232,[email protected],Entered
2,japan,CURRENT,MR,Charlie,Delta,02/03/2001,21313,213,kor,north,3232,[email protected],Approved
3,indo,CURRENT,MS,Echo,Foxtrot,03/04/2002,21313,213,kor,north,3232,[email protected],Entered
4,MY,SAVINGS,MR,Golf,Hotel,04/05/2003,21313,213,kor,north,3232,[email protected],Entered
5,SG,CURRENT,MRS,India,Juliet,05/06/2004,21313,213,kor,north,3232,[email protected],Approved
6,china,CURRENT,MS,Kilo,Lima,06/07/2005,21313,213,kor,north,3232,[email protected],Entered
7,turkey,CURRENT,MR,Mike,November,07/08/2006,21313,213,kor,north,3232,[email protected],Entered
8,chile,CURRENT,MRsr,Mike,November,07/08/2006,21313,213,kor,north,3232,[email protected],rejected
9,poland,CURRENTs,MR,Mike,November,07/08/2006,21313,213,kor,north,3232,[email protected],Entered
通过 SQLLDR,
这是我的错误。文本
Record 8: Rejected - Error on table ACCOUNTREQUEST.
ORA-02290: check constraint (HR.CHK_TITLE) violated
Record 9: Rejected - Error on table ACCOUNTREQUEST.
ORA-02290: check constraint (HR.CHK_ACCOUNTS) violated
Table ACCOUNTREQUEST:
7 Rows successfully loaded.
2 Rows not loaded due to data errors.
0 Rows not loaded because all WHEN clauses were failed.
0 Rows not loaded because all fields were null.
我想使用 shell 脚本来计算成功加载的行数
并没有加载以及为什么(就像记录 8 和 9 中所说的那样)
附言。由于限制只允许 (MR,MRS,MS) 作为标题,(SAVINGS,CURRENT) 作为帐户类型,因此未插入数据
我已经可以通过 shell 脚本计算被拒绝的数量
grep -wc "rejected" txtsample.txt
但无法将其回显到 error.log,我还需要错误的原因,即记录 8 和 9