aspose file tools *
The moose likes JDBC and the fly likes inserting data into two tables simultaniously Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "inserting data into two tables simultaniously" Watch "inserting data into two tables simultaniously" New topic
Author

inserting data into two tables simultaniously

preddy south
Greenhorn

Joined: Aug 29, 2006
Posts: 7
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

Joined: Aug 13, 2004
Posts: 1081

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


Gravitation cannot be held responsible for people falling in love ~ Albert Einstein
Rajesh Agarwal
Ranch Hand

Joined: Aug 01, 2005
Posts: 79
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

Joined: May 24, 2003
Posts: 425
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

Joined: Aug 29, 2006
Posts: 7
Thanks a lot for your help.
 
jQuery in Action, 2nd edition
 
subject: inserting data into two tables simultaniously