Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

inserting data into two tables simultaniously

 
preddy south
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

My requirement is to insert data i.e form data from an JSP page into two independent tables with single insert statement.Data base is Oracle.

Thanks in advance..
 
Shailesh Chandra
Ranch Hand
Posts: 1082
Java Oracle Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just out of curosity, could you tell us what is limiting you to execute only one insert query. you can use a trigger to solve your purpose or use a stored procedure


Shailesh
 
Rajesh Agarwal
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1 way is to set a trigger on the first table. The trigger would be
AFTER INSERT


CREATE OR REPLACE TRIGGER Trigger_Name AFTER INSERT OR UPDATE OR DELETE
 
Purushoth Thambu
Ranch Hand
Posts: 425
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are using Oracle 9i then you can try this method


You need to select from a table/view inorder to do multitable insert. You can make this as prepared statement and bind the form values to placeholders in dual select.
 
preddy south
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot for your help.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic