Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Import data from CSV to Oracle

Posted on 2016-09-12
4
Medium Priority
?
54 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 38

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 2000 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

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

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…
How to Unravel a Tricky Query Introduction If you browse through the Oracle zones or any of the other database-related zones you'll come across some complicated solutions and sometimes you'll just have to wonder how anyone came up with them.  …
This video explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.
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.

636 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