Solved

Import data from CSV to Oracle

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Oracle query output question 4 36
Wrong number of values in the INTO list of a FETCH statement 16 47
help on oracle query 5 33
Oracle - SQL Parse String 5 20
Article by: Swadhin
From the Oracle SQL Reference (http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/queries006.htm) we are told that a join is a query that combines rows from two or more tables, views, or materialized views. This article provides a glimps…
Have you ever had to make fundamental changes to a table in Oracle, but haven't been able to get any downtime?  I'm talking things like: * Dropping columns * Shrinking allocated space * Removing chained blocks and restoring the PCTFREE * Re-or…
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.

867 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

15 Experts available now in Live!

Get 1:1 Help Now