문제

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. 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. My main problem right now though is that even though it says 42 rows have been commited, my table is still empty.

** Just an FYI, I am using a excel spreadsheet save as .csv. The reason I am practicing with an excel file is because sooner or later I will be automating this process for a project. **

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:

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')",

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top