使用Oracle sql loader加载时出错

时间:2016-11-25 09:41:18

标签: oracle sql-loader

我真的不知道问题出在哪里。我希望你能提供帮助。

这是数据文件:

01/04/2013$1.300
01/10/2015$0.100
01/12/2016$0.500

此文件必须在TableA中加载:

  • 2列:thedate (type DATE)和therate (type NUMBER(5,3))

这是ctl文件:

LOAD DATA
REPLACE
INTO TABLE TABLEA
FIELDS TERMINATED BY '$'
TRAILING NULLCOLS
(THEDATE,
THERATE "to_number(:THERATE, '99999D999', 'NLS_NUMERIC_CHARACTERS=''.,''')")

正在加载,我在所有记录的日志中都有此错误:

Column Name                  Position   Len  Term Encl Datatype
THEDATE                             FIRST     *   $       CHARACTER            
THERATE                             NEXT     *   $       CHARACTER            
SQL string for column : "to_number(:THERATE, '99999D999', 'NLS_NUMERIC_CHARACTERS=''.,''')"
  

记录1:拒绝 - 表TABLEA,列THERATE出错。   ORA-01438:大于此列允许的指定精度的值

1 个答案:

答案 0 :(得分:1)

相同的代码(只是很少修改但与你的错误无关)对我来说很好。

[oracle@localhost Desktop]$ cat data.txt 
01/04/2013$1.300
01/10/2015$0.100
01/12/2016$0.500

[oracle@localhost Desktop]$ cat control.ctl 
LOAD DATA
INFILE 'data.txt'
REPLACE
INTO TABLE TABLEA
FIELDS TERMINATED BY '$'
TRAILING NULLCOLS
(THEDATE "to_date(:THEDATE, 'MM-DD-YYYY')",
THERATE "to_number(:THERATE, '99999D999', 'NLS_NUMERIC_CHARACTERS=''.,''')")

[oracle@localhost Desktop]$ sqlldr jay/jay control file=control.ctl

SQL*Loader: Release 11.2.0.4.0 - Production on Fri Nov 25 16:04:50 2016

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

Commit point reached - logical record count 4
[oracle@localhost Desktop]$ sqlplus jay/jay

SQL*Plus: Release 11.2.0.4.0 Production on Fri Nov 25 16:04:56 2016

Copyright (c) 1982, 2013, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> select * from tablea;                   

THEDATE      THERATE
--------- ----------
04-JAN-13        1.3
10-JAN-15         .1
12-JAN-16         .5