Click here to Skip to main content
15,996,590 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have two tables master(id,productName,Code,productDetail) and sub master(id,productName,Code,productDetail) I insert value from a single query in both table then I want that if Data is not insert into submaster because of any exception then data is insert in submaster from master table.
Posted

Well, before any resolution, I don't get why one would have a copy of same table and just call one as master and other as submaster! (Not just a copy, insert same values into both of them.)

Surely, some issue in your design and explaining what you are trying to do might get you more better approach/resolution. For now, a simple transaction with commit/rollback option can do the stuff for you.
 
Share this answer
 
v2
Its simple.
Get ID (may be MAX) value from master table & & submaster.
Then compare both.


If problem occured then submaster ID will not same as master's one.
so , insert from master to submaster
Else
do nothing both executed successfully.


OR use batch query processing & transaction commitment properties available in java or .net. Go for google for more programmatic way to deal with multiple query execution instead u r doing here in a single query fire.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900