Solved

Import data from CSV to Oracle

Posted on 2016-09-12
4
31 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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
Configuring and using Oracle Database Gateway for ODBC Introduction First, a brief summary of what a Database Gateway is.  A Gateway is a set of driver agents and configurations that allow an Oracle database to communicate with other platforms…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
This video shows how to Export data from an Oracle database using the Original Export Utility.  The corresponding Import utility, which works the same way is referenced, but not demonstrated.

777 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