1

更新:我的问题已经解决,只是想添加一些我偶然发现的有用的代码。这将帮助您更轻松地制作 .ctl 文件。希望这对那里的某些人有用。

select
'LOAD DATA 
APPEND
INTO TABLE ' || '&TABLE_NAME' ||
' FIELDS TERMINATED BY "~"
TRAILING NULLCOLS
(' "Column Name",' ' "sql_loader_type" from dual
union all
select
COLUMN_NAME,
DECODE(DATA_TYPE,
'TIMESTAMP(6)','TIMESTAMP "YYYY-MM-DD HH24:MI:SS.FF",',
'NUMBER','DECIMAL EXTERNAL,',
'VARCHAR2','CHAR,',
'CHAR','CHAR',
'DATE','"TO_DATE(SUBSTR(:' || column_name || ',1,19),''YYYY-MM-DD HH24:MI:SS'')",'
) "sql_loader_type"
from all_tab_cols 
where owner=UPPER('&SCHEMA_NAME') AND TABLE_NAME = UPPER('&TABLE_NAME')
union all
select ')' "Column Name" , '' "sql_loader_type" from dual;

我正在尝试使用 SQL Loader 来更好地理解它,到目前为止它非常有趣。我现在的主要问题是,即使它说已经提交了 42 行,我的表仍然是空的。

** 仅供参考,我正在使用另存为 .csv 的 Excel 电子表格。我使用 excel 文件练习的原因是因为迟早我会为一个项目自动化这个过程。**

对日志文件的进一步审查表明我收到一条错误消息,指出我缺少一列。这是我的ctl文件的设置方式:

options (skip=11, errors=10,rows=45)
load DATA
  infile 'location of my file'
  INTO TABLE t_legal_transactions
  fields terminated BY "," optionally enclosed by '"' trailing nullcols
  (ACCOUNT,
   transaction_date "to_date(:transaction_date, 'DD_MON_YY'",
   amount,
   fintran_id,
   attorney_id,
   description,
   ID constant '1',
   batch_id constant '1',
   org_id constant '239')

这是破译可怕的死亡线后日志显示的内容:

Record 1: Rejected - Error on table T_LEGAL_TRANSACTIONS, column ORG_ID.
ORA-00917: missing comma
Record 2: Rejected - Error on table T_LEGAL_TRANSACTIONS, column ORG_ID.
ORA-00917: missing comma
Record 3: Rejected - Error on table T_LEGAL_TRANSACTIONS, column ORG_ID.
ORA-00917: missing comma
Record 4: Rejected - Error on table T_LEGAL_TRANSACTIONS, column ORG_ID.
ORA-00917: missing comma
Record 5: Rejected - Error on table T_LEGAL_TRANSACTIONS, column ORG_ID.
ORA-00917: missing comma
Record 6: Rejected - Error on table T_LEGAL_TRANSACTIONS, column ORG_ID.
ORA-00917: missing comma
Record 7: Rejected - Error on table T_LEGAL_TRANSACTIONS, column ORG_ID.
ORA-00917: missing comma
Record 8: Rejected - Error on table T_LEGAL_TRANSACTIONS, column ORG_ID.
ORA-00917: missing comma
Record 9: Rejected - Error on table T_LEGAL_TRANSACTIONS, column ORG_ID.
ORA-00917: missing comma
Record 10: Rejected - Error on table T_LEGAL_TRANSACTIONS, column ORG_ID.
ORA-00917: missing comma

现在我一直在网上搜索,试图找出导致此错误的原因,但我一无所获。这里有人能指出我正确的方向吗?

还有一个问题,是否可以格式化日志以使其看起来不可怕?

4

1 回答 1

1

关闭这一行的括号:

transaction_date "to_date(:transaction_date, 'DD_MON_YY'",

transaction_date "to_date(:transaction_date, 'DD_MON_YY')",

于 2013-08-21T18:54:19.960 回答