• 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

how to insert into 2 tables at a time?

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
JDBC EDB Tomcat
--------------------------
when I built up the Database, I seperate a customer's information into 2 tables in 1 database.

when I get customer's information from a html form, I try to insert these information into 2 tables at the same time, the 2 tables have a cust_id as the same coloum,
-----------------------
the question is:
how can I control when inserting the data, if one of the sql failed, the other successed one could roll back?
 
Ranch Hand
Posts: 333
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by david hongw wang:
JDBC EDB Tomcat
--------------------------
when I built up the Database, I seperate a customer's information into 2 tables in 1 database.

when I get customer's information from a html form, I try to insert these information into 2 tables at the same time, the 2 tables have a cust_id as the same coloum,
-----------------------
the question is:
how can I control when inserting the data, if one of the sql failed, the other successed one could roll back?



Using a database that properly supports transactions (many but not all):



If your database doesn't support transactions, then it's real real hard and I don't want to hurt my brain tonight trying to remember how to do that. In fact, there are enough free and cheap databases that do support transactions correctly that there's no point in wasting good brain cells on the problem.
 
reply
    Bookmark Topic Watch Topic
  • New Topic