ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 使用awk查找不满足sqlloader加载条件的记录

使用awk查找不满足sqlloader加载条件的记录

原创 Linux操作系统 作者:redhouser 时间:2013-05-29 21:14:28 0 删除 编辑
使用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/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2011-05-26

  • 博文量
    211
  • 访问量
    876698