简体   繁体   English

由于比较对象cmdlet导致加载.txt文件时,SQL Loader失败

[英]SQL Loader failing while loading a .txt file which is a result of compare-object cmdlet

I receive a fixed format file out of a legacy application that is loaded to an oracle table by SQL loader daily. 我从旧版应用程序中收到固定格式的文件,该文件每天都由SQL加载程序加载到oracle表中。 A new requirement needs Day 1 and Day 2 files to be compared and only the difference to be appended, so the data at the end of day 2 looks like Day 1(initial load) + Day 2 - Day 1(changes only). 一个新的需求需要比较第一天和第二天的文件,并且只添加差异,因此第二天结束时的数据看起来像第一天(初始负载)+第二天-第一天(仅更改)。

I'm using below command to find out the difference between 2 files 我正在使用下面的命令来找出2个文件之间的区别

Compare-Object -referenceObject $(Get-Content $File1) -differenceObject $(Get-Content $File2) | Compare-Object -referenceObject $(获取内容$ File1)-differenceObject $(获取内容$ File2)| %{$ .Inputobject + $ .SideIndicator} | %{$ .Inputobject + $ .SideIndicator} | ft -auto | ft -auto | out-file $fileDiff.txt -width 5000 外文件$ fileDiff.txt -width 5000

A sample first line from the output of compare-object looks like below: 比较对象输出的第一行示例如下所示:

4614 TESTUC1 32570544900721657 4614 TESTUC1 32570544900721657

The control file reads the infile as below: 控制文件读取infile如下:

PER_ID POSITION(1:8) CHAR TERMINATED BY WHITESPACE, PER_ID POSITION(1:8)由WHITESPACE终止,

USER_ID POSITION(9:16) CHAR TERMINATED BY WHITESPACE, USER_ID POSITION(9:16)由WHITESPACE终止,

USER_ID_PREV POSITION(17:24) CHAR TERMINATED BY WHITESPACE, USER_ID_PREV POSITION(17:24)由WHITESPACE终止,

Logs give me an error reason for discarding all records as follows: 日志给我一个丢弃所有记录的错误原因,如下所示:

Record 1: Rejected - Error on table PDB_EXPORT_DELTA, column PER_ID. 记录1:已拒绝-在表PDB_EXPORT_DELTA的PER_ID列上出错。 ORA-01722: invalid number ORA-01722:编号无效

I'm not sure if it is due to the FileDiff.txt not being in fixed format anymore or SQLLoader not recognizing it as a fixed format anymore. 我不确定这是由于FileDiff.txt不再是固定格式还是SQLLoader不再将其识别为固定格式。

I've researched both aspects and haven't found anything on Compare-Object preserving or altering the format of the output difference file, nor have seen anything on type-casting values in SQLLoader control file. 我已经对这两个方面进行了研究,但是在CompareObject保留或更改输出差异文件的格式方面没有发现任何东西,也没有在SQLLoader控制文件中的类型转换值上看到任何东西。 Any help is much appreciated. 任何帮助深表感谢。 Thoughts on other ways of achieving the before said requirement is also welcome. 也欢迎对实现上述要求的其他方式进行思考。 TIA TIA

我的SQL Loader版本(显然是您的版本)默认为8位字符集,因此您可以A)使用Notepad ++(或等效版本)将文件转换为8位,或者B)更新powershell脚本以将文件创建为8位或C)查看SQL Loader控制文件中CHARACTERSET子句的使用

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM