It's not a secret anymore!
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
JavaRanch » Java Forums » Products » Oracle/OAS
Bookmark "Invoking SQL Loader from Java" Watch "Invoking SQL Loader from Java" New topic

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

Joined: Aug 22, 2010
Posts: 3733

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.

I agree. Here's the link:
subject: Invoking SQL Loader from Java
It's not a secret anymore!