my dog learned polymorphism*
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
Author

Shell script to run sqlldr

Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9345
    
    2

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: 15958
    
  19

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.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Shell script to run sqlldr
 
Similar Threads
Executing sqlplus or sqlldr from java code
Writing many records to an Oracle table
CSV+truncate leading zero solution
Running external application with stdin as argument
Trouble in executing sqlldr through java