简体   繁体   English

SQL Loader缺少逗号错误

[英]SQL Loader missing comma error

UPDATE: My problem was solved, just wanted to add this helpful bit of code I stumbled upon. 更新:我的问题解决了,只想添加我偶然发现的这段有用的代码。 This will help you make a .ctl file much easier. 这将帮助您简化.ctl文件。 Hopefully this is of use to some people out there. 希望这对那里的某些人有用。

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;

I am trying to play around with SQL Loader to get a better understand of it and so far its been very interesting. 我正在尝试使用SQL Loader来更好地理解它,到目前为止,它非常有趣。 My main problem right now though is that even though it says 42 rows have been commited, my table is still empty. 我现在的主要问题是,即使它说已提交42行,我的表仍然是空的。

** Just an FYI, I am using a excel spreadsheet save as .csv. **仅供参考,我正在使用另存为.csv的Excel电子表格。 The reason I am practicing with an excel file is because sooner or later I will be automating this process for a project. 我使用excel文件进​​行练习的原因是因为我迟早会为项目自动化该过程。 ** **

Further review of the log file shows that I am getting an error saying that I am missing a column. 进一步查看日志文件显示,我收到一条错误消息,说我缺少一列。 Here is how my ctl file is set up: 这是我的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')

Here is what the log shows after deciphering the terrible one line of death: 这是破译一条可怕的死亡线后日志显示的内容:

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

Now I have been scouring the internet trying to find what might be the cause of this error, but I am coming up with nothing. 现在,我一直在搜寻互联网,以查找可能导致此错误的原因,但是我什么也没想到。 Can anyone here point me in the right direction? 这里有人可以指出正确的方向吗?

Also side question, is it possible to format the log so its not terrible to look at? 还有一个侧面的问题,是否有可能对日志进行格式化,使其看起来并不可怕?

close your parenthesis on this line: 在此行上关闭括号:

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

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

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

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