Solved

sqlldr fails with ORA-01858: a non-numeric character was found where a numeric was expected

Posted on 2010-08-12
5
3,640 Views
Last Modified: 2013-12-19
Hi

I have the following table and data (tab delimited):

CREATE TABLE "TEST"."ACCOUNT_TRANSACTION_HISTORY"
   (      "TRANSACTION_ID" VARCHAR2(20 BYTE),
      "CURRENCY" VARCHAR2(20 BYTE),
      "ACCOUNT_ID" VARCHAR2(20 BYTE),
      "ACCOUNT_NO" VARCHAR2(20 BYTE),
      "ACCOUNT_HOLDER_CLIENT_CODE" VARCHAR2(20 BYTE),
      "ACCOUNT_USER_CLIENT_CODE" VARCHAR2(20 BYTE),
      "TRANSACTION_DATE" DATE,
      "TRANSACTION_TYPE" VARCHAR2(20 BYTE),
      "STATEMENT_DESCRIPTION" VARCHAR2(20 BYTE),
      "FEE_AMOUNT" VARCHAR2(20 BYTE),
      "TRANSACTION_AMOUNT" VARCHAR2(20 BYTE)
   ) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
  STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
  PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
  TABLESPACE "USERS" ;

Account ID      Account Number      Account Holder Client Code      Account User Client Code      Transaction Date       Business Transaction Id      Business Transaction Code      Statement Description      Currency      Fee Amount      Transaction Amount      Current Balance      Available Balance      Business Transaction Reference
1006      100010      00001      00002      10/06/2010 16:55:32      125      Generation      Generation      BHD      0      -200100      9999799800      9999799800      1026

I have tried loading this data using sqlldr with the following control file:

load data
   infile 'Account_Transaction_History.csv'
   replace
   into table ACCOUNT_TRANSACTION_HISTORY
   fields terminated by X'09'
   TRAILING NULLCOLS
(
 TRANSACTION_ID,
 CURRENCY,
 ACCOUNT_ID,
 ACCOUNT_NO,
 ACCOUNT_HOLDER_CLIENT_CODE,
 ACCOUNT_USER_CLIENT_CODE,
 TRANSACTION_DATE "to_date(:TRANSACTION_DATE, 'DD/MM/YYYY HH24:MI:SS')",
 TRANSACTION_TYPE,
 STATEMENT_DESCRIPTION,
 FEE_AMOUNT,
 TRANSACTION_AMOUNT
)

and get the following error:


SQL*Loader: Release 10.2.0.1.0 - Production on Fri Jun 25 11:26:51 2010

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

Control File:   C:\temp\ath.ctl
Data File:      Account_Transaction_History.csv
  Bad File:     C:\temp\Account_Transaction_History.bad
  Discard File:  none specified
 
 (Allow all discards)

Number to load: ALL
Number to skip: 2
Errors allowed: 1000000
Bind array:     64 rows, maximum of 256000 bytes
Continuation:    none specified
Path used:      Conventional
Silent options: FEEDBACK
Table ACCOUNT_TRANSACTION_HISTORY, loaded from every logical record.
Insert option in effect for this table: REPLACE
TRAILING NULLCOLS option in effect

   Column Name                  Position   Len  Term Encl Datatype
------------------------------ ---------- ----- ---- ---- ---------------------
TRANSACTION_ID                      FIRST     *  WHT      CHARACTER            
CURRENCY                             NEXT     *  WHT      CHARACTER            
ACCOUNT_ID                           NEXT     *  WHT      CHARACTER            
ACCOUNT_NO                           NEXT     *  WHT      CHARACTER            
ACCOUNT_HOLDER_CLIENT_CODE           NEXT     *  WHT      CHARACTER            
ACCOUNT_USER_CLIENT_CODE             NEXT     *  WHT      CHARACTER            
TRANSACTION_DATE                     NEXT     *  WHT      CHARACTER            
    SQL string for column : "to_date(:TRANSACTION_DATE, 'DD/MM/YYYY HH24:MI:SS')"
TRANSACTION_TYPE                     NEXT     *  WHT      CHARACTER            
STATEMENT_DESCRIPTION                NEXT     *  WHT      CHARACTER            
FEE_AMOUNT                           NEXT     *  WHT      CHARACTER            
TRANSACTION_AMOUNT                   NEXT     *  WHT      CHARACTER            

Record 1: Rejected - Error on table ACCOUNT_TRANSACTION_HISTORY, column TRANSACTION_DATE.
ORA-01858: a non-numeric character was found where a numeric was expected

If I play around with the settings I sometimes get a different response but can't get the data to actually load.

Any help would be appreciated.

Matt
0
Comment
Question by:MattDuPlessis
5 Comments
 
LVL 23

Expert Comment

by:David
Comment Utility
A quick pass and I should have looked this up, but my eyes caught on the colon used to begin the column ("to_date(:TRANSACTION)  -- that's where I'd expect the syntax error to arise.  I'll try to check this out further later today.
0
 
LVL 8

Expert Comment

by:LindaC
Comment Utility
Hi.

This is the modified ctl, please see the TRANSACTION_DATE line, a NULLIF TRANSACTION_DATE=BLANKS

load data
   infile 'Account_Transaction_History.csv'
   replace
   into table ACCOUNT_TRANSACTION_HISTORY
   fields terminated by X'09'
   TRAILING NULLCOLS
(
 TRANSACTION_ID,
 CURRENCY,
 ACCOUNT_ID,
 ACCOUNT_NO,
 ACCOUNT_HOLDER_CLIENT_CODE,
 ACCOUNT_USER_CLIENT_CODE,
 TRANSACTION_DATE "to_date(:TRANSACTION_DATE, 'DD/MM/YYYY HH24:MI:SS')" NULLIF TRANSACTION_DATE=BLANKS,
 TRANSACTION_TYPE,
 STATEMENT_DESCRIPTION,
 FEE_AMOUNT,
 TRANSACTION_AMOUNT
)
0
 
LVL 76

Accepted Solution

by:
slightwv (䄆 Netminder) earned 500 total points
Comment Utility
First: you have 11 columns in the control file and 14 columns in your data.

Second:  TRANSACTION_DATE is the 7th column in your control file and the 5th in the data provided.

Third:  Do the column heading exist in the CSV file?  If so you need to SKIP 1.

Given the table definition above, I trimmed down the example you gave and tested this using 10.2.0.3.  Make sure the file is tab separated and Experts-Exchange doesn't remove the tabs.

options (skip=1)

load data

   infile *

   replace

   into table ACCOUNT_TRANSACTION_HISTORY

   fields terminated by X'09'

   TRAILING NULLCOLS

(

 ACCOUNT_ID,

 ACCOUNT_NO,

 ACCOUNT_HOLDER_CLIENT_CODE,

 ACCOUNT_USER_CLIENT_CODE,

 TRANSACTION_DATE "to_date(:TRANSACTION_DATE, 'DD/MM/YYYY HH24:MI:SS')"

)

BEGINDATA

Account	Number	Client	Code	Transaction Date

1007	100010	00001	00002	10/06/2010 16:55:32

Open in new window

0
 

Author Closing Comment

by:MattDuPlessis
Comment Utility
Resolved
0
 
LVL 76

Expert Comment

by:slightwv (䄆 Netminder)
Comment Utility
Can I ask what more I could have provided to receive an 'A' grade?
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Truncate is a DDL Command where as Delete is a DML Command. Both will delete data from table, but what is the difference between these below statements truncate table <table_name> ?? delete from <table_name> ?? The first command cannot be …
I remember the day when someone asked me to create a user for an application developement. The user should be able to create views and materialized views and, so, I used the following syntax: (CODE) This way, I guessed, I would ensure that use…
Via a live example, show how to restore a database from backup after a simulated disk failure using RMAN.
This video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now