使用SQL loader时出错

时间:2013-10-06 08:46:55

标签: sql oracle10g sql-loader

我正在尝试使用 SQL loader 将数据从.dat文件导入到oracle数据库中的表。

控制文件:

LOAD DATA
infile 'E:\labs\labs\lab_18_06.dat'
INTO TABLE INVENTORY.PRODUCT_ON_HAND
APPEND
FIELDS TERMINATED BY ','
(on_hand_id,
product_id,
quantity,
warehouse_city char(30),
last_update date(12) 'DD-MON-YYYY')

数据文件包含如下记录:

5001,1001,7,Atlanta,01-FEB-2004

数据库中的表:

SQL> desc inventory.product_on_hand;
 Name                                      Null?    Type
 ----------------------------------------- -------- ----------------------------
 ON_HAND_ID                                NOT NULL NUMBER(5)
 PRODUCT_ID                                         NUMBER(7)
 QUANTITY                                           NUMBER(5)
 WAREHOUSE_CITY                                     VARCHAR2(30)
 LAST_UPDATE                                        DATE

我在.log文件中收到以下错误:

Record 1: Failed - Error in the table INVENTORY.PRODUCT_ON_HAND, column LAST_UPDATE.
ORA-01843: month not valid

请帮助解决我的问题!

更新:

SQL> select sysdate from dual;

SYSDATE
-----------
06-OCT-2013

我设置nls_lang='american'nls_date_format='DD-MON-YYYY',但这没有帮助/

坏文件:

5001,1001,7,Atlanta,01-FEB-2004
5002,1001,7,Chicago,01-FEB-2004
5003,1001,7,Orlando,01-FEB-2004
5004,1002,7,Atlanta,01-FEB-2004
5005,1002,7,Chicago,01-FEB-2004
5006,1002,7,Orlando,01-FEB-2004
5007,1003,7,Atlanta,01-FEB-2004
5008,1003,7,Chicago,01-FEB-2004
5009,1003,7,Orlando,01-FEB-2004
5010,1004,7,Atlanta,01-FEB-2004
5011,1004,7,Chicago,01-FEB-2004
5012,1004,7,Orlando,01-FEB-2004
5013,1005,7,Atlanta,01-FEB-2004
5014,1005,7,Chicago,01-FEB-2004
5015,1005,7,Orlando,01-FEB-2004
5016,1006,7,Atlanta,01-FEB-2004
5017,1006,7,Chicago,01-FEB-2004
5018,1006,7,Orlando,01-FEB-2004
5019,1007,7,Chicago,01-FEB-2004
5020,1007,7,Orlando,01-FEB-2004
5021,1007,7,Atlanta,01-FEB-2004
5022,1008,7,Chicago,01-FEB-2004
5023,1008,7,Orlando,01-FEB-2004
5024,1008,7,Atlanta,01-FEB-2004
5025,1009,7,Chicago,01-FEB-2004
5026,1009,7,Orlando,01-FEB-2004
5027,1009,7,Atlanta,01-FEB-2004
5028,1010,7,Chicago,01-FEB-2004
5029,1010,7,Orlando,01-FEB-2004
5030,1010,7,Atlanta,01-FEB-2004
5031,1010,7,Chicago,01-FEB-2004
5032,1011,7,Orlando,01-FEB-2004
5033,1011,7,Atlanta,01-FEB-2004
5034,1012,7,Chicago,01-FEB-2004
5035,1012,7,Orlando,01-FEB-2004
5036,1012,7,Atlanta,01-FEB-2004
5037,1013,7,Chicago,01-FEB-2004
5038,1013,7,Orlando,01-FEB-2004
5039,1014,7,Atlanta,01-FEB-2004
5040,1014,7,Chicago,01-FEB-2004
5041,1015,7,Atlanta,01-FEB-2004
5042,1015,7,Chicago,01-FEB-2004
5043,1015,7,Orlando,01-FEB-2004
5044,1016,7,Atlanta,01-FEB-2004
5045,1016,7,Chicago,01-FEB-2004
5046,1016,7,Orlando,01-FEB-2004
5047,1017,7,Atlanta,01-FEB-2004
5048,1017,7,Chicago,01-FEB-2004
5049,1017,7,Orlando,01-FEB-2004
5050,1018,7,Atlanta,01-FEB-2004
5051,1018,7,Chicago,01-FEB-2004

2 个答案:

答案 0 :(得分:0)

尝试

alter session set nls_date_language='american'; 

LOAD DATA
infile 'E:\labs\labs\lab_18_06.dat'
INTO TABLE INVENTORY.PRODUCT_ON_HAND
APPEND
FIELDS TERMINATED BY ','
(on_hand_id,
product_id,
quantity,
warehouse_city char(30),
last_update date(12) 'DD-MON-YYYY')

答案 1 :(得分:0)

问题是你在控制文件中指定了12个数字:last_update date(12) 'DD-MON-YYYY',这是不正确的。

您应该将其设为last_update date 'DD-MON-YYYY'

SO控制文件应为:

LOAD DATA
infile 'E:\labs\labs\lab_18_06.dat'
INTO TABLE INVENTORY.PRODUCT_ON_HAND
APPEND
FIELDS TERMINATED BY ','
(on_hand_id,
product_id,
quantity,
warehouse_city char(30),
last_update date 'DD-MON-YYYY')