You should create a transaction at the begining of the insert code and close it at the end.
Do not delete anything if there is an error.
The transaction will roll back all data if there is a problem (all you need is an exception when the error occurred).

Best regards,
Mihai

On Fri, 2006-02-03 at 05:57 -0500, Baz wrote:
Hi,

Lets say you have a method AddCustomer() that adds a customer into your DB.
A customer, however, is related to several other CFCs and DB tables such as
Addess, phone, email, etc. (each their own CFCs). So the AddCustomer()
method looks something like this:

. InsertCustomer()
. If error, exit
. InsertPhone()
. If error: DeleteCustomer(), exit
. InsertEmail()
. If error: DeletePhone(), DeleteCustomer(), exit
. etc...

If this goes on for a few more Inserts, you could see the last "If error"
having a lot of Deletes.

Is this a reasonable way of going about this? Anything I should?

Cheers,
Baz





----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email to cfcdev@cfczone.org with the words 'unsubscribe cfcdev' as the subject of the email.

CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting (www.cfxhosting.com).

An archive of the CFCDev list is available at www.mail-archive.com/cfcdev@cfczone.org


----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email to cfcdev@cfczone.org with the words 'unsubscribe cfcdev' as the subject of the email.

CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting (www.cfxhosting.com).

An archive of the CFCDev list is available at www.mail-archive.com/cfcdev@cfczone.org

Reply via email to