Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiple Table data entry, how to remove entered data, on error

Status
Not open for further replies.

ChrisMacPherson

Programmer
Jul 3, 2000
157
0
0
GB
Hi All,

I have a problem here, which I think will probably need a tutorial to solve, so any appropriate links will be VERY appreciated.

I have a database with seven tables which hold details of a customers account. Each table holding seperate kinds of details (ie. address's, account config etc. etc.) I have set up primary keys and no foreign keys as they do not function in MySQL.

Now how do I implement the system so:

When I enter data to the tables, if there is an error on one table, then all the previous data that has been entered should be removed again. As if no entry has been made.

I am thinking about a making a function which is called when the error is found that will delete the last row of the tables that data has been entered into. Does this sound right or is there an easier way to do this?

If anybody has any links to using relationships in MySQL then I will be a very happy person!!! Chris MacPherson
thedamager@hotmail.com
Bring on the new Browza's!!
 
What you are asking for is called a transaction in a database program. Let's say you have 3 queries you want to use, and if any 1 query fails, all the tables revert back to the way it was before the query run. If you need that's that's called a transaction.

Unfortunately, until very recently, MySQL does not have transaction support. There are several ways around this, but since it is a rather complicated issue, the best way is to consult the MySQL on-line manual located at
 
Thanks azzkicar,

I'll have a look in the manual. Usefull tip, that would have taken me ages to find out that it was called a transaction!!

Cheers Chris MacPherson
thedamager@hotmail.com
Bring on the new Browza's!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top