我正在使用Linux shell中的Oracle Sql Loader Utility将csv数据加载到Oracle DB中。我试图根据另一列的值填充DB中一列的值。但我的解码函数似乎无法正常工作。
PFB样品。我使用COMPANY_NAME的值来填充供应商ID的字段值,因为供应商ID不是csv文件的一部分。
ctl文件:
LOAD DATA
APPEND INTO TABLE .MESSAGE_ARCHIVE_DATA
FIELDS TERMINATED BY '|'
OPTIONALLY ENCLOSED BY '"'
TRAILING NULLCOLS
(
TRANSACTION_DATE "to_date(:TRANSACTION_DATE,'YYYYMMDD')",
COMPANY_NAME "decode(trim(:COMPANY_NAME), null, 'NULL', :COMPANY_NAME)",
ARCHIVER_NAME "decode(trim(:ARCHIVER_NAME), null, 'NULL', :ARCHIVER_NAME)",
ECPD,
ACCOUNT_NUMBER,
MDN_COUNT,
VENDOR_ID "decode(TRIM(:COMPANY_NAME),'XXX',1001,
'YYY',1002,
'NULL')",
SERVICE constant 'INC_MSGARCHIVE',
STATUS constant "A",
DATE_OF_ENTRY "SYSDATE"
)
csv文件:
20161102|XYZ|XXX|652659|3111110199-169
Record 1: Rejected - Error on table MESSAGE_ARCHIVE_DATA, column VENDOR_ID.,ORA-01722: invalid number