Я видел различные подобные вопросы, но ни одно из решений, похоже, не работает для меня.
Мне дали файл CSV, созданный на мэйнфрейме, который мне нужно загрузить в Oracle.Я решил попробовать сопоставить его с внешней таблицей Oracle, а затем использовать его для вставки в Oracle.
Это мой CSV:
CONTRACT_NUMBER,PRODUCTCODE,TRANSACTION_NUMBER,EFFECTIVE_DATE,AMENDMENT,TERM,ACTIVE,AGENT_NUMBER,PREMIUM,ICRATE,RCRATE,IC_ALLOW,RC_ALLOW,SPRATE,TRANSACTION_CODE,TRANSACTION_DATE,AGENT_CATEGORY,AGENT_SALES_CODE,FREQ,TOT_PREMTD,REFERENCE,ALTERNATIVE_COMMISSION_METHOD,PAXUS_REF_ID
PAXUSCT1,MAA,1,07/10/2017,NB,12,Y,2905,6000,,,1,1,,T642,,,,,6000,,,
PAXUSCT1,MAA,2,07/05/2018,INC,11,Y,2905,2400,90,3,1,1,,,,,,,8400,,,
PAXUSCT2,MAA,1,01/06/2018,NB,12,Y,T1000,540,,,1,1,,,,,,,540,,,
PAXUSCT3,MAA,1,05/06/2018,NB,12,Y,T1000,1200,,,1,1,,,,,,,1200,,,
Я создал это определение, и многиедругие варианты этого, но я продолжаю получать ошибки:
create table LD_CMS_BASIS_MIGRATION
(
contract_number VARCHAR2(8),
productcode VARCHAR2(3),
transaction_number NUMBER,
effective_date DATE,
amendment VARCHAR2(3),
term NUMBER,
active VARCHAR2(1),
agent_number VARCHAR2(5),
premium NUMBER,
icrate NUMBER,
rcrate NUMBER,
ic_allow NUMBER,
rc_allow NUMBER,
sprate NUMBER,
transaction_code VARCHAR2(4),
transaction_date DATE,
agent_category VARCHAR2(4),
agent_sales_code VARCHAR2(4),
freq VARCHAR2(1),
tot_premtd NUMBER,
reference VARCHAR2(40),
alternative_commission_method VARCHAR2(40),
paxus_ref_id VARCHAR2(8)
)
organization external
(
type ORACLE_LOADER
default directory MIGRATIONS
access parameters
(
records field names all files
fields CSV without embedded record terminators
)
location (MIGRATIONS:'CMS_BASIS_MIG.csv')
)
reject limit UNLIMITED;
Когда я пытаюсь прочитать из него, я получаю эту ошибку:
Вот чтов файле журнала на сервере:
KUP-05004: Warning: Intra source concurrency disabled because parallel select was not requested.
Field Definitions for table LD_CMS_BASIS_MIGRATION
Record format DELIMITED BY NEWLINE
Data in file has same endianness as the platform
Rows with all null fields are accepted
Fields in Data Source:
CONTRACT_NUMBER CHAR (255)
Terminated by ","
Enclosed by """ and """
Trim whitespace same as SQL Loader
PRODUCTCODE CHAR (255)
Terminated by ","
Enclosed by """ and """
Trim whitespace same as SQL Loader
TRANSACTION_NUMBER CHAR (255)
Terminated by ","
Enclosed by """ and """
Trim whitespace same as SQL Loader
EFFECTIVE_DATE CHAR (255)
Terminated by ","
Enclosed by """ and """
Trim whitespace same as SQL Loader
AMENDMENT CHAR (255)
Terminated by ","
Enclosed by """ and """
Trim whitespace same as SQL Loader
TERM CHAR (255)
Terminated by ","
Enclosed by """ and """
Trim whitespace same as SQL Loader
ACTIVE CHAR (255)
Terminated by ","
Enclosed by """ and """
Trim whitespace same as SQL Loader
AGENT_NUMBER CHAR (255)
Terminated by ","
Enclosed by """ and """
Trim whitespace same as SQL Loader
PREMIUM CHAR (255)
Terminated by ","
Enclosed by """ and """
Trim whitespace same as SQL Loader
ICRATE CHAR (255)
Terminated by ","
Enclosed by """ and """
Trim whitespace same as SQL Loader
RCRATE CHAR (255)
Terminated by ","
Enclosed by """ and """
Trim whitespace same as SQL Loader
IC_ALLOW CHAR (255)
Terminated by ","
Enclosed by """ and """
Trim whitespace same as SQL Loader
RC_ALLOW CHAR (255)
Terminated by ","
Enclosed by """ and """
Trim whitespace same as SQL Loader
SPRATE CHAR (255)
Terminated by ","
Enclosed by """ and """
Trim whitespace same as SQL Loader
TRANSACTION_CODE CHAR (255)
Terminated by ","
Enclosed by """ and """
Trim whitespace same as SQL Loader
TRANSACTION_DATE CHAR (255)
Terminated by ","
Enclosed by """ and """
Trim whitespace same as SQL Loader
AGENT_CATEGORY CHAR (255)
Terminated by ","
Enclosed by """ and """
Trim whitespace same as SQL Loader
AGENT_SALES_CODE CHAR (255)
Terminated by ","
Enclosed by """ and """
Trim whitespace same as SQL Loader
FREQ CHAR (255)
Terminated by ","
Enclosed by """ and """
Trim whitespace same as SQL Loader
TOT_PREMTD CHAR (255)
Terminated by ","
Enclosed by """ and """
Trim whitespace same as SQL Loader
REFERENCE CHAR (255)
Terminated by ","
Enclosed by """ and """
Trim whitespace same as SQL Loader
ALTERNATIVE_COMMISSION_METHOD CHAR (255)
Terminated by ","
Enclosed by """ and """
Trim whitespace same as SQL Loader
PAXUS_REF_ID CHAR (255)
Terminated by ","
Enclosed by """ and """
Trim whitespace same as SQL Loader
KUP-04117: Field name PAXUS_REF_ID
was not found in the access parameter field list or table.
KUP-04093: error processing the FIELD NAMES record in data file /u02/CAMS/MIGRATIONS/dataload/CMS_BASIS_MIG.csv
Любая помощь приветствуется.
Спасибо, Mac
################## РЕДАКТИРОВАТЬ
Ответ от Tajesh ниже, в значительной степени.Это то, что сработало.Я думаю, что команда Newline - то, что в основном добилось целиКогда я отредактировал CSV-файл и добавил запятую в конце каждой строки, он прекрасно поднял последний столбец.Я также должен был добавить маску даты тоже.Но решение Tajesh означает, что мне не нужно редактировать файл CSV.
create table LD_CMS_BASIS_MIGRATION
(
contract_number VARCHAR2(8),
productcode VARCHAR2(3),
transaction_number NUMBER,
effective_date DATE,
amendment VARCHAR2(3),
term NUMBER,
active VARCHAR2(1),
agent_number VARCHAR2(5),
premium NUMBER,
icrate NUMBER,
rcrate NUMBER,
ic_allow NUMBER,
rc_allow NUMBER,
sprate NUMBER,
transaction_code VARCHAR2(4),
transaction_date DATE,
agent_category VARCHAR2(4),
agent_sales_code VARCHAR2(4),
freq VARCHAR2(1),
tot_premtd NUMBER,
reference VARCHAR2(40),
alternative_commission_method VARCHAR2(40),
paxus_ref_id VARCHAR2(8)
)
ORGANIZATION EXTERNAL ( TYPE ORACLE_LOADER
DEFAULT DIRECTORY "MIGRATIONS" ACCESS PARAMETERS (
RECORDS DELIMITED BY NEWLINE
BADFILE 'CMS_BASIS_MIG_BAD.bad'
LOGFILE 'CMS_BASIS_MIG_LOG.log'
SKIP 1
FIELDS TERMINATED BY ','
DATE_FORMAT DATE MASK "dd/mm/yyyy"
MISSING FIELD VALUES ARE NULL
) LOCATION ( 'CMS_BASIS_MIG.csv' )
) REJECT LIMIT UNLIMITED
PARALLEL 5;