使用sql*loader加载数据时,出现了不满足加载条件的记录,加载日志如下:
Total logical records skipped: 0
Total logical records read: 30961
Total logical records rejected: 0
Total logical records discarded: 485
加载控制文件中有如下条件:
WHEN (10:36)='000000000000000000000000000' AND (68:69) = '00'
而在加载时没有指定discard参数,如何获取不满足加载条件的记录?
这里使用awk解决:
--满足条件的记录个数:
cat ALL.INQREFAC.asc|awk '{if ( substr($0,10,27) == "000000000000000000000000000" && substr($0,68,2) == "00" ) {print $0}}'|wc -l
--不满足条件的记录
cat ALL.INQREFAC.asc|awk '{if ( substr($0,10,27) != "000000000000000000000000000" || substr($0,68,2) != "00" ) {print $0}}'
--不满足条件的记录
cat ALL.INQREFAC.asc|awk '{if ( substr($0,10,27) != "000000000000000000000000000" || substr($0,68,2) != "00" ) {print substr($0,10,27),"",substr($0,68,2)}}'
当然,最简单的方法是加载时指定discard参数。
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/18922393/viewspace-762382/
,如需转载,请注明出处,否则将追究法律责任。