• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Import data from database with sequence as primary key

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HI all,

I want to import data from another database using JDBC. All the tables have sequence as the primary key and the sequences on the source and destination need not match. I want to enter data into 'N' related tables (having the sequence column as the foreign key) in a single transaction. What is the best approach to achieve this?

Thanks in advance

 
Preeti Prabhakar
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, let me make my question more clear.
I have a Java application (job) which receives data for multiple tables from another schema. These tables have DB sequence as the primary key. Now I want to replicate the data from this schema onto my schema using a Java program. How can i handle sequences and Foreign key references to these sequences while executing the java job?

Thanks in advance.
 
Marshal
Posts: 79151
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to JavaRanch
 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Preeti,

in which format your job receives the input data? is it Flat file or delimited file or Excel or some other?

whatever it may be, in the output schema why do you bother about the sequence of the input schema.
Just consider that as input field and persist in your resultant DB schema. If you want you can make that column as PK.

If you have FK columns, first in the referred table then referring table.

 
Preeti Prabhakar
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Krish for the response...

I get the input as a flat file.

Say, I have 3 related tables... Student -> Student_Address -> Location. Each of these tables have Sequence as primary key.
I have to import data for all the 3 tables in the same transaction. Is it possible?

Thanks
 
krish laks
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Preeti,

I assume Student and Location are independent tables. And Student_Address is dependent on both these tables.
Also from your mail I understand you will get Student_id (PK of student table), Location_id (PK of Location table).
So, you first insert these two tables and then insert the Student_Address table.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic