Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Merging a data from one table into other.

 
Ram singh
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I have two table that have exactly the same fields. So, i created a new table and want to merge both of the tables rows into this new table. I have a wrapper classes for both tables and currently want to just merge one of those 2 tables in the new one. This is wut i wrote:

String sessionid = "";
PrivateSession ps = new PrivateSession(sessionid); //wrapper class for the old table
THis is the query that i wrote:
query = " INSERT INTO Tempsession VALUES(" + ps.sessionid +",\"" + ps.performerid + "\",'PRIVATE', \"" + ps.passcode + "\", \"" + ps.featid + "\",\"" + ps.refid + "\"," + starttime +", " + endtime +","+ ps.duration +", "+ ps.endreason +", " + ps.rate +", " + ps.pays +")";
// PRIVATE IS teh value for all the rows for that particluar column.
it compiles and runs with Java command. but when i do a query on Tempsession, it returns empty???...Anyone have any idea why its doing that...Any help would be greatly appreciated. THanks a lot.
 
Gayathri Prasad
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ram,
There might be 2 possibilties.
1) You are not handling the run-time exceptions
2) There might not be any data from the session which you are using wrapper class (PrivateSession).
Cheers,
Gaya3
 
Ram singh
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey,
I can post both the classes here or can email them. I really need help with this. I'll really aprreciate it. THanks..
 
Ram singh
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Or, is there a way i can directly insert the values from the old table into the new one without having to use the wrapper class for the old table..THanks..
 
Joel McNary
Bartender
Posts: 1840
Eclipse IDE Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should be able just to issues a SQL statement to acheive this. Try somethign along the lines of:
 
Ram singh
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have one more field in the new table that doesn't exist in the old one..so, how would i put that in as well..adn plus, i tried to run ur query and its giving me a nullPointerException during run....
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic