File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Linux / UNIX and the fly likes Shell script to run sqlldr Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "Shell script to run sqlldr" Watch "Shell script to run sqlldr" New topic

Shell script to run sqlldr

Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 10032


I'm looking to write a shell script to run sqlldr command to insert bulk data and this sqlldr will be called through a cron job. My question here is, first how to write a shell that connects to the database, reads the file and inserts the records? The following is what I have,

Oracle 11g database
the file is a .ctl file and a .csv data file

I have to run this command from the location where my app server is installed and my db server is a different machine. I have oracle client installed on my app server.

SCJP 1.4, SCWCD 1.4 - Hints for you, Certified Scrum Master
Did a rm -R / to find out that I lost my entire Linux installation!
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17410

sqlldr will handle the database reads and writes. Just set up a simple shell script to do what you'd do if you were running sqlldr manually. If you want to put the sqlldr directives inline in the script, you can use the "here" feature:

The "<<" starts off the "here" data stream and indicates that a line with the value of "EOF" marks the end of the data. You'll have to supply your own sqlldr options - I'm afraid that since nobody wants to pay me to do Oracle these days, I don't recall the details and I'm too lazy to RTFM.

An IDE is no substitute for an Intelligent Developer.
I agree. Here's the link:
subject: Shell script to run sqlldr
jQuery in Action, 3rd edition