wood burning stoves 2.0*
The moose likes JDBC and the fly likes Choice of Implementation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Choice of Implementation" Watch "Choice of Implementation" New topic
Author

Choice of Implementation

Harish Vembu
Ranch Hand

Joined: Jul 19, 2004
Posts: 33

Dear members and Ranchers,

I have a requirement as follows

I need to read a tab delimited file from a directory and parse it and load into the oracle database.

The application process may be run as a cron job

The data is to be loaded onto different tables based on what each field data in the text file represents.The tables are related based on different columns in the tables.(I have the ER diagram and know the relationship)

I had seen some posts here and elsewhere that SQLLoader is a way to do it through a Java application. Also being mentioned that its better in performance comparison to using JDBC application.

My first choice as per above would be to go for SQLLoader but since I have to load different columns in seperate tables in a schema I am having a doubt that SQL Loader may not serve the purpose here.

If anyone gives me a suggestion/better idea/choice/working example/tutorial, I would feel better before I take up this task.


Any quick help would be much appreciated.


Thanks & Best Regards

Harish


Harish
SCJP ,SCDJWS
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30075
    
149

Harish,
SQLLoader can handle multiple tables. See the sample control file in the Oracle FAQ.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Harish Vembu
Ranch Hand

Joined: Jul 19, 2004
Posts: 33

Dear Members and Ranchers,

I am here again with another query

Thanks Jeanne for the reply.

Nice to know about loading to mutliple tables. Can we have SQL join queries executed as a part of SQL Loader data insertion/updation.

I am looking for a smart way of loading data based on SQL join performed on mutiple tables.

In short what I need to know is

I have load data from a tab delimited file after performing SQL join on mutiple tables which satisfy certain conditions. Is it possible with SQL Loader.

Can it work as part of standalone Java application?

Best Regards

Harish
Paul Campbell
Ranch Hand

Joined: Oct 06, 2007
Posts: 338
Harish,

Are you asking if you can update/insert to columns where the columns exist in different tables in a single SQL statement by joining the tables?
Harish Vembu
Ranch Hand

Joined: Jul 19, 2004
Posts: 33

Dear Ranchers,

Yes Paul,I am lookng for insertion/updation of columns present in different Oracle tables by SQL Join through Oracle SQL Loader?

The main point is that I want to achieve it through SQL Loader and Java

I hope this is clear

If so can you give me a sample code?

Thanks & Best Regards

Harish
Paul Campbell
Ranch Hand

Joined: Oct 06, 2007
Posts: 338
Harish,

If you want to keep it simple, do your update via two sql statements.

If you have some reason that you must do it (update columns in different tables in a single SQL statement, you can only do that via an updatable view (as long as it meets the criteria to be an updatable view. These are the rules (for Oracle anyway, but will be similar elsewhere):

The following notes apply to updatable views:

An updatable view is one you can use to insert, update, or delete base table rows. You can create a view to be inherently updatable, or you can create an INSTEAD OF trigger on any view to make it updatable.

To learn whether and in what ways the columns of an inherently updatable view can be modified, query the USER_UPDATABLE_COLUMNS data dictionary view. The information displayed by this view is meaningful only for inherently updatable views. For a view to be inherently updatable, the following conditions must be met:

*

Each column in the view must map to a column of a single table. For example, if a view column maps to the output of a TABLE clause (an unnested collection), then the view is not inherently updatable.

*

The view must not contain any of the following constructs:

A set operator
A DISTINCT operator
An aggregate or analytic function
A GROUP BY, ORDER BY, MODEL, CONNECT BY, or START WITH clause
A collection expression in a SELECT list
A subquery in a SELECT list
A subquery designated WITH READ ONLY
Joins, with some exceptions, as documented in Oracle Database Administrator's Guide

*

In addition, if an inherently updatable view contains pseudocolumns or expressions, then you cannot update base table rows with an UPDATE statement that refers to any of these pseudocolumns or expressions.
*

If you want a join view to be updatable, then all of the following conditions must be true:
o

The DML statement must affect only one table underlying the join.
o

For an INSERT statement, the view must not be created WITH CHECK OPTION, and all columns into which values are inserted must come from a key-preserved table. A key-preserved table is one for which every primary key or unique key value in the base table is also unique in the join view.
o

For an UPDATE statement, the view must not be created WITH CHECK OPTION, and all columns updated must be extracted from a key-preserved table.
*

For a DELETE statement, if the join results in more than one key-preserved table, then Oracle Database deletes from the first table named in the FROM clause, whether or not the view was created WITH CHECK OPTION.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Choice of Implementation
 
Similar Threads
Invoking SQL Loader from java vs JDBC application
SQL Loader help
SQLLoader for Data Migration
Fastest way to insert 1 Lac records in a table
A good choice of ORM framework for my application?