-----Original Message-----
From: Ben Johnson [mailto:[EMAIL PROTECTED] 
Sent: Monday, August 15, 2005 12:18 AM
To: [email protected]
Subject: Re: [RLUG] Is there a database guru out there?

If you want to make sure all or nothing happens then use transactions.
In this situation, I'd say adding a new customer could be considerred an
operation that may be performed with or without a new order being
successfully linked, so there's no reason to bind the two insertions in
this way.  just create a new customer, then somehow get the new customer
id and use that as part of the order data you insert later.  If a
customer cannot exist without a linked order then do a "BEGIN"
transaction before you insert anything, then "COMMIT or "ROLLBACK"
depending on whether errors were encountered.


My suggestion here would be that you have a CustID field in the order
table that has a foreign_key constraint. That means any insertion will
fail if the CustomerID does not exist in the Customer Table.



- Ben

_______________________________________________
RLUG mailing list
[email protected]
http://lists.rlug.org/mailman/listinfo/rlug


_______________________________________________
RLUG mailing list
[email protected]
http://lists.rlug.org/mailman/listinfo/rlug

Reply via email to