Solved

Import data from CSV to Oracle

Posted on 2016-09-12
4
22 Views
Last Modified: 2016-10-30
Hi,
I am trying to import data from my csv file to new oracle table.

this is my ctrl file -

LOAD DATA
INFILE 'D:\CSV_TEST\JOBLISTCREATEDATE_25590909174500.txt'
BADFILE 'D:\CSV_TEST\JOBLISTCREATEDATE_25590909174500.bad'
DISCARDFILE 'D:\CSV_TEST\JOBLISTCREATEDATE_25590909174500.dsc'

INTO TABLE "OS_DELI_ALLOC_CSV_HAFL"
APPEND

FIELDS TERMINATED BY ','
TRAILING NULLCOLS

  (DACH_TXN
,
   DACH_JOB_ID
,
   DACH_RCV_DT
,
   DACH_RCV_TIME
,
   DACH_RCV_LAT
,
   DACH_RCV_LON
,
   DACH_REJ_RES
,
   DACH_IMG_1
,
   DACH_IMG_2
)

and like below statement i am executing through BAT file.
Its not getting any error. also not get the data in my oracle table .
Kindly help.

$ sqlldr HTHTEST/HTHTEST@HTHTEST CONTROL= strl_csv.ctl skip=1
0
Comment
Question by:ashok p
4 Comments
 
LVL 37

Expert Comment

by:Geert Gruwez
ID: 41795492
what does your csv look like ?
1
 

Author Comment

by:ashok p
ID: 41795494
LIKE THIS

"DO_GEN-1600134852","166242","09/09/2016","11:04:08","13.61974000","100.39130000",,"Sign-D-20160909110245.jpg","CD-20160909110249.jpg"
"DO_GEN-1600135924","166242","09/09/2016","15:45:19","13.58309000","100.29380000",,"Sign-D-20160909154043.jpg","CD-20160909154048.jpg"
0
 
LVL 34

Accepted Solution

by:
johnsone earned 500 total points
ID: 41795836
Using your sample control file and sample data (with a header line added), then creating a table with this statement:
create table OS_DELI_ALLOC_CSV_HAFL
  (DACH_TXN varchar2(100),
   DACH_JOB_ID varchar2(100),
   DACH_RCV_DT varchar2(100),
   DACH_RCV_TIME varchar2(100),
   DACH_RCV_LAT varchar2(100),
   DACH_RCV_LON varchar2(100),
   DACH_REJ_RES varchar2(100),
   DACH_IMG_1 varchar2(100),
   DACH_IMG_2 varchar2(100)
);

Open in new window

The data loaded just fine.

A couple of notes:

You may want to change this:

FIELDS TERMINATED BY ','

to

FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'

Also, in your sample command line, there is a space between CONTROL= and the name of the file.  If that is just a cut and paste issue, then no problem, but there shouldn't be a space there in the real command line (it may or may not work).

Is this an issue where it works when you run it by command line, but fails when you run it by batch file?  If so, posting the batch file would be helpful.

Also, what is in the strl_csv.log file?
1

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 …
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
This video shows how to copy a database user from one database to another user DBMS_METADATA.  It also shows how to copy a user's permissions and discusses password hash differences between Oracle 10g and 11g.
This video shows setup options and the basic steps and syntax for duplicating (cloning) a database from one instance to another. Examples are given for duplicating to the same machine and to different machines

743 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

16 Experts available now in Live!

Get 1:1 Help Now