SQLLDR - WHEN 子句的问题

发布于 2024-10-18 01:16:17 字数 2341 浏览 0 评论 0原文

我的控制文件中有多个when 子句,我加载其中一半的数据满足when 子句并插入到所需的表中。另一半不是(我期望的),但我期望将不满足条件的数据放入丢弃文件中,但没有创建任何数据。

有什么想法吗?

LOAD DATA
INFILE '/u04/app/vpht_app/flat_files/icr_load/marc/sqlldr_load/CSSO_CCRBSCREDENTIALS_COMSUMER23062010160322.txt'
BADFILE '/u04/app/vpht_app/flat_files/icr_load/marc/sqlldr_load/CSSO_CCRBSCREDENTIALS_COMSUMER23062010160322.bad'
DISCARDFILE '/u04/app/vpht_app/flat_files/icr_load/marc/sqlldr_load/CSSO_CCRBSCREDENTIALS_COMSUMER23062010160322.dsc'
INSERT

INTO TABLE "DCVPAPP"."RBS_CC_CUSTOMERINFO"
INSERT
FIELDS TERMINATED BY ','
TRAILING NULLCOLS
(CC_USER_NAME POSITION(24:73),
ACCOUNTID POSITION(1:12),
CUSTOMERID POSITION(14:22))

INTO TABLE "DCVPAPP"."RBS_CC_SECURITYDETAILS"
WHEN (481:481) = 'N' AND (477:479) ='0'
FIELDS TERMINATED BY ','
TRAILING NULLCOLS
(
CC_USER_NAME POSITION(24:73),
RBSPIN POSITION(75:274),
RBSPASSWORD POSITION(276:475),
fill1 filler,
fill2 filler,
fill3 filler,
fill4 filler,
FAILCODECOUNT POSITION(477:479),
FAILPASSWORDCOUNT POSITION(477:479)
)

INTO TABLE "DCVPAPP"."RBS_CC_SECURITYDETAILS"
WHEN (481:481) = 'N' AND (477:479) ='1'
FIELDS TERMINATED BY ','
TRAILING NULLCOLS
(
CC_USER_NAME POSITION(24:73),
RBSPIN POSITION(75:274),
RBSPASSWORD POSITION(276:475),
fill1 filler,
fill2 filler,
fill3 filler,
fill4 filler,
FAILCODECOUNT POSITION(477:479),
FAILPASSWORDCOUNT POSITION(477:479)
)

我的表结构是:

Create table RBS_CC_CUSTOMERINFO
(
CC_USER_NAME VARCHAR2(50),
ACCOUNTID VARCHAR2(12) NOT NULL,
CUSTOMERID VARCHAR2(9) NOT NULL,
CUST_MIGRATION_STATUS VARCHAR2(1) DEFAULT 'N' NOT NULL,
CONSTRAINT pk_01 PRIMARY KEY (CC_USER_NAME)
);

Create table RBS_CC_SECURITYDETAILS
(
CC_USER_NAME VARCHAR2(50),
RBSPIN VARCHAR2(200) NOT NULL,
RBSPASSWORD VARCHAR2(200) NOT NULL,
FAILCODECOUNT NUMBER (9) NOT NULL,
FAILPASSWORDCOUNT NUMBER (9) NOT NULL,
CONSTRAINT pk_secur
FOREIGN KEY (CC_USER_NAME)
REFERENCES RBS_CC_CUSTOMERINFO(CC_USER_NAME)
)

我的示例数据如下(这些已被正确填充,因为这些是固定字段)最后一条记录应被丢弃并放置在丢弃文件中,因为它不满足任何when子句条件,但不丢弃文件已创建。我已经用一个when子句尝试过,并创建了丢弃文件,似乎使用了多个表,未创建丢弃文件。

ACC000000001,CUSTID213,MARC_VAF ,1234 ,pet ,0 ,N,N,FULL
ACC000000002,CUSTID214,TOBY_123 ,1352 ,bailey ,1 ,Y,N,FULL
ACC000000003,CUSTID215,KEVIN_VAF81 ,YY33OF ,water ,2 ,Y,N,FULL
ACC000000015,CUSTID227,SAM_EGD ,CARRY42 ,some password ,-3 ,Y,N,FULL

谢谢

I have multiple when clauses in my control file, the data that i am loading in half of them satisfies the when clauses and gets inserted into the desired table. The other half arent (which i expect) but i was expecting the data that doesnt meet the when conditions to be placed into a discard file but there is none created.

Any ideas?

LOAD DATA
INFILE '/u04/app/vpht_app/flat_files/icr_load/marc/sqlldr_load/CSSO_CCRBSCREDENTIALS_COMSUMER23062010160322.txt'
BADFILE '/u04/app/vpht_app/flat_files/icr_load/marc/sqlldr_load/CSSO_CCRBSCREDENTIALS_COMSUMER23062010160322.bad'
DISCARDFILE '/u04/app/vpht_app/flat_files/icr_load/marc/sqlldr_load/CSSO_CCRBSCREDENTIALS_COMSUMER23062010160322.dsc'
INSERT

INTO TABLE "DCVPAPP"."RBS_CC_CUSTOMERINFO"
INSERT
FIELDS TERMINATED BY ','
TRAILING NULLCOLS
(CC_USER_NAME POSITION(24:73),
ACCOUNTID POSITION(1:12),
CUSTOMERID POSITION(14:22))

INTO TABLE "DCVPAPP"."RBS_CC_SECURITYDETAILS"
WHEN (481:481) = 'N' AND (477:479) ='0'
FIELDS TERMINATED BY ','
TRAILING NULLCOLS
(
CC_USER_NAME POSITION(24:73),
RBSPIN POSITION(75:274),
RBSPASSWORD POSITION(276:475),
fill1 filler,
fill2 filler,
fill3 filler,
fill4 filler,
FAILCODECOUNT POSITION(477:479),
FAILPASSWORDCOUNT POSITION(477:479)
)

INTO TABLE "DCVPAPP"."RBS_CC_SECURITYDETAILS"
WHEN (481:481) = 'N' AND (477:479) ='1'
FIELDS TERMINATED BY ','
TRAILING NULLCOLS
(
CC_USER_NAME POSITION(24:73),
RBSPIN POSITION(75:274),
RBSPASSWORD POSITION(276:475),
fill1 filler,
fill2 filler,
fill3 filler,
fill4 filler,
FAILCODECOUNT POSITION(477:479),
FAILPASSWORDCOUNT POSITION(477:479)
)

My table structure is:

Create table RBS_CC_CUSTOMERINFO
(
CC_USER_NAME VARCHAR2(50),
ACCOUNTID VARCHAR2(12) NOT NULL,
CUSTOMERID VARCHAR2(9) NOT NULL,
CUST_MIGRATION_STATUS VARCHAR2(1) DEFAULT 'N' NOT NULL,
CONSTRAINT pk_01 PRIMARY KEY (CC_USER_NAME)
);

Create table RBS_CC_SECURITYDETAILS
(
CC_USER_NAME VARCHAR2(50),
RBSPIN VARCHAR2(200) NOT NULL,
RBSPASSWORD VARCHAR2(200) NOT NULL,
FAILCODECOUNT NUMBER (9) NOT NULL,
FAILPASSWORDCOUNT NUMBER (9) NOT NULL,
CONSTRAINT pk_secur
FOREIGN KEY (CC_USER_NAME)
REFERENCES RBS_CC_CUSTOMERINFO(CC_USER_NAME)
)

and my sample data is below( These have been right padded since these are fixed fields) the last record should be discarded and placed in side the discard file since it doesnt meet any of the when clause conditions, but no discard file is created. I have tried it with one when clause and the discard file is created,seems using more than one table the discard file isnt created.

ACC000000001,CUSTID213,MARC_VAF ,1234 ,pet ,0 ,N,N,FULL
ACC000000002,CUSTID214,TOBY_123 ,1352 ,bailey ,1 ,Y,N,FULL
ACC000000003,CUSTID215,KEVIN_VAF81 ,YY33OF ,water ,2 ,Y,N,FULL
ACC000000015,CUSTID227,SAM_EGD ,CARRY42 ,some password ,-3 ,Y,N,FULL

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

夜空下最亮的亮点 2024-10-25 01:16:17

我对示例数据使用了 SQL*Loader,并在 SQL*Loader 留下的日志文件中发现了以下内容:

Table "DCVPAPP"."RBS_CC_CUSTOMERINFO":
  4 Rows successfully loaded.      
  0 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.

Table "DCVPAPP"."RBS_CC_SECURITYDETAILS":
  0 Rows successfully loaded.
  0 Rows not loaded due to data errors.
  4 Rows not loaded because all WHEN clauses were failed.
  0 Rows not loaded because all fields were null.

Table "DCVPAPP"."RBS_CC_SECURITYDETAILS":
  0 Rows successfully loaded.
  0 Rows not loaded due to data errors.
  4 Rows not loaded because all WHEN clauses were failed.
  0 Rows not loaded because all fields were null.

在第一个块中,所有数据均已加载,因为没有 WHEN 子句会失败。对于另外两行,所有行均未通过 WHEN 子句。由于第一个块加载了所有四行,因此没有任何内容可写入丢弃文件,因此 SQL*Loader 没有创建一个。

后两个块中的 WHEN 子句似乎引用了距离示例数据末尾很远的部分数据。它们似乎都使用位置 477 以后的数据,而示例数据中最长的行只有 68 个字符长。由于每个字段最多有一个尾随空格,因此我假设您的示例数据已被破坏,并且应该有比上面更多的空格。

不管怎样,我注释掉了控制文件中插入 RBS_CC_CUSTOMERINFO 的部分,清空了表并重新运行 SQL*Loader。这次,所有四行都被写入丢弃文件。

如果您希望将与两个 WHEN 子句都不匹配的数据写入丢弃文件,如何将控制文件拆分为两个单独的控制文件,其中一个将数据加载到 RBS_CC_CUSTOMERINFO 使用第一个块,然后使用其他两个块将数据加载到 RBS_CC_SECURITYDETAILS 中?

I used SQL*Loader on your sample data, and found the following in the log file that SQL*Loader left behind:

Table "DCVPAPP"."RBS_CC_CUSTOMERINFO":
  4 Rows successfully loaded.      
  0 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.

Table "DCVPAPP"."RBS_CC_SECURITYDETAILS":
  0 Rows successfully loaded.
  0 Rows not loaded due to data errors.
  4 Rows not loaded because all WHEN clauses were failed.
  0 Rows not loaded because all fields were null.

Table "DCVPAPP"."RBS_CC_SECURITYDETAILS":
  0 Rows successfully loaded.
  0 Rows not loaded due to data errors.
  4 Rows not loaded because all WHEN clauses were failed.
  0 Rows not loaded because all fields were null.

In the first block, all the data was loaded because there were no WHEN clauses to fail. With the other two, all rows failed the WHEN clauses. Since the first block loaded all four rows, there was nothing to write to the discard file, so SQL*Loader didn't create one.

The WHEN clauses in the second two blocks seem to reference parts of the data a long way off the end of your sample data. They both appear to use data from positions 477 onwards, whereas the longest line in your sample data is only 68 characters long. Since each field has at most one trailing space, I'll assume that your sample data has somehow got mangled and that there should be many more spaces than as above.

Anyway, I commented out the section of your controlfile that inserts into RBS_CC_CUSTOMERINFO, emptied the tables and reran SQL*Loader. This time, all four rows were written to the discard file.

If you want data that matches neither of the two WHEN clauses to be written to a discard file, how about splitting the controlfile into two separate controlfiles, one which loads the data into RBS_CC_CUSTOMERINFO using the first block, and one which loads the data into RBS_CC_SECURITYDETAILS using the other two blocks?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文