This week's book giveaway is in the JavaFX forum.
We're giving away four copies of Introducing JavaFX 8 Programming and have Herbert Schildt on-line!
See this thread for details.
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


Win a copy of Introducing JavaFX 8 Programming this week in the JavaFX forum!
JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "Shell script to run sqlldr" Watch "Shell script to run sqlldr" New topic
Author

Shell script to run sqlldr

Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9967
    
    3

Guys,

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: 17142
    
  27

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.
 
 
subject: Shell script to run sqlldr
 
It's not a secret anymore!