This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Oracle/OAS and the fly likes Invoking SQL Loader from Java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Products » Oracle/OAS
Bookmark "Invoking SQL Loader from Java" Watch "Invoking SQL Loader from Java" New topic
Author

Invoking SQL Loader from Java

Charles Owen
Ranch Hand

Joined: Aug 31, 2009
Posts: 61
I have a code snippet working in which I am invoking SQL Loader from Java. However, I would like to make the table name in the control file dynamic. Is there a way to set the table name to a variable in the control file and assign this variable a value outside of the control file within Java?
Martin Vajsar
Sheriff

Joined: Aug 22, 2010
Posts: 3610
    
  60

I didn't find any information about variables in control file in the docs. However, given that you're running the whole thing from Java, you could easily create the control file for each run and stuff the required table name into it.

If your program can access to a file system your database server can see, you could also consider external tables. Generally, anything that can be processed using SQL Loader can be processed by external tables. The "loading" is then done using a SQL command (insert into your_target_table as select from external_table) which would clearly be fully under your control.
Badal Chowdhary
Ranch Hand

Joined: Apr 26, 2011
Posts: 34

You can use ProcessBuilder class in Java to invoke any executable. So you can have your sqlldr command in a bat file, and invoke this bat file from Java.


Blog: http://badalchowdhary.wordpress.com/
Twitter: http://twitter.com/badalrocks
 
wood burning stoves
 
subject: Invoking SQL Loader from Java