Solved

Import data from CSV to Oracle

Posted on 2016-09-12
4
47 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 35

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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Working with Network Access Control Lists in Oracle 11g (part 1) Part 2: http://www.e-e.com/A_9074.html So, you upgraded to a shiny new 11g database and all of a sudden every program that used UTL_MAIL, UTL_SMTP, UTL_TCP, UTL_HTTP or any oth…
How to Create User-Defined Aggregates in Oracle Before we begin creating these things, what are user-defined aggregates?  They are a feature introduced in Oracle 9i that allows a developer to create his or her own functions like "SUM", "AVG", and…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
This video shows how to recover a database from a user managed backup

717 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