更新:我的问题解决了,只是想添加我偶然发现的这段有用的代码。这将有助于您更轻松地创建.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行,我的表仍然是空的。
**仅仅是一个FYI,我使用excel电子表格另存为.csv。我使用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
现在我一直在搜索互联网,试图找出导致此错误的原因,但我什么也没想到。这里有人能指出我正确的方向吗?
另外的问题是,是否可以格式化日志以便查看它并不可怕?
答案 0 :(得分:1)
在此行上关闭括号:
transaction_date“to_date(:transaction_date,'DD_MON_YY'”,
transaction_date“to_date(:transaction_date,'DD_MON_YY')”,