生成 ORA-00984 的 sqlldr:此处不允许列 - 在尝试添加常量文本时

sqlldr generating ORA-00984: column not allowed here - while trying to add constant text

我需要将几个类似的 csv 文件加载到工作 tables 中,格式相同以进行后续处理,但对于某些数据,我收到 'ORA-00984: column not allowed here' 错误。

我无法更改 csv 的布局,但作品中的列顺序 table 和 sqlldr 控制文件的格式都在我的控制之下。

我需要更改什么才能让 sqlldr 加载此数据?

编辑:解决方案:对 .ctl 文件进行以下更改: col6_fixedchar constant "abc", 修复了这个问题,有趣的是 sqlldr 非常乐意将“3600”解释为数字。

下面是一个示例:

table:

create table test_sqlldr
(
    col1_date date,
    col2_char varchar2(15),
    col3_int number(5),
    col4_int number(5),
    col5_int number(5),
    -- fixed and dummy fields
    col6_fixedchar varchar2(15),
    col7_nullchar varchar2(20),
    col8_fixedint number(5)
);

csv:

cat /tmp/test_sqlldr.csv
2019-08-27 09:00:00,abcdefghi,3600,0,0
2019-08-27 09:00:00,jklmnopqr,3600,0,0
2019-08-27 09:00:00,stuvwxyza,3600,3598,3598
2019-08-27 09:00:00,bcdefghij,3600,0,0

ctl:

cat /tmp/test_sqlldr.ctl
load data infile '/tmp/test_sqlldr.csv'
insert into table test_sqlldr
fields terminated by ',' optionally enclosed by '"' TRAILING NULLCOLS
(
    col1_date timestamp 'yyyy-mm-dd hh24:mi:ss',
    col2_char,
    col3_int,
    col4_int,
    col5_int,
    col6_fixedchar "abc",
    col8_fixedint "3600"
)

这会生成以下输出:

/opt/oracle/product/112020_cl_64/cl/bin/sqlldr <db credentials> control='/tmp/test_sqlldr.ctl' ; cat test_sqlldr.log

SQL*Loader: Release 12.2.0.1.0 - Production on Wed Aug 28 10:26:00 2019

Copyright (c) 1982, 2017, Oracle and/or its affiliates.  All rights reserved.

Path used:      Conventional
Commit point reached - logical record count 4

Table TEST_SQLLDR:
  0 Rows successfully loaded.

Check the log file:
  test_sqlldr.log
for more information about the load.

SQL*Loader: Release 12.2.0.1.0 - Production on Wed Aug 28 10:26:00 2019

Copyright (c) 1982, 2017, Oracle and/or its affiliates.  All rights reserved.

Control File:   /tmp/test_sqlldr.ctl
Data File:      /tmp/test_sqlldr.csv
  Bad File:     /tmp/test_sqlldr.bad
  Discard File:  none specified

 (Allow all discards)

Number to load: ALL
Number to skip: 0
Errors allowed: 50
Bind array:     64 rows, maximum of 256000 bytes
Continuation:    none specified
Path used:      Conventional

Table TEST_SQLLDR, loaded from every logical record.
Insert option in effect for this table: INSERT
TRAILING NULLCOLS option in effect

   Column Name                  Position   Len  Term Encl Datatype
------------------------------ ---------- ----- ---- ---- ---------------------
COL1_DATE                           FIRST     *   ,  O(") DATETIME yyyy-mm-dd hh24:mi:ss
COL2_CHAR                            NEXT     *   ,  O(") CHARACTER
COL3_INT                             NEXT     *   ,  O(") CHARACTER
COL4_INT                             NEXT     *   ,  O(") CHARACTER
COL5_INT                             NEXT     *   ,  O(") CHARACTER
COL6_FIXEDCHAR                       NEXT     *   ,  O(") CHARACTER
    SQL string for column : "abc"
COL8_FIXEDINT                        NEXT     *   ,  O(") CHARACTER
    SQL string for column : "3600"

Record 1: Rejected - Error on table TEST_SQLLDR, column COL4_INT.
ORA-00984: column not allowed here

Record 2: Rejected - Error on table TEST_SQLLDR, column COL4_INT.
ORA-00984: column not allowed here

Record 3: Rejected - Error on table TEST_SQLLDR, column COL4_INT.
ORA-00984: column not allowed here

Record 4: Rejected - Error on table TEST_SQLLDR, column COL4_INT.
ORA-00984: column not allowed here


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


Space allocated for bind array:                 115584 bytes(64 rows)
Read   buffer bytes: 1048576

Total logical records skipped:          0
Total logical records read:             4
Total logical records rejected:         4
Total logical records discarded:        0

Run began on Wed Aug 28 10:26:00 2019
Run ended on Wed Aug 28 10:26:00 2019

Elapsed time was:     00:00:00.14
CPU time was:         00:00:00.03

尝试:col6_fixedchar常数"abc"