Doh! That's true! Only need to explicitly rollback for example if there
is something else inside of the transaction tags that is NOT a db query
and hence won't necessarily exit the transaction automatically e.g.
<cftransaction>
...DB Queries
<cf_chargecreditcard>
<cfif chargeError>
<cftransaction action="rollback"/>
</cfif>
</cftransaction>
...but...this was not what the original question was so I'll shut up
now!
Andr�
-----Original Message-----
From: Dave Watts [mailto:[EMAIL PROTECTED]]
Sent: 18 February 2003 16:00
To: CF-Talk
Subject: RE: CFTransaction and looping through multiple inserts
> No need to have a separate "CommitWrite" variable. Just do
> this:
>
> <cftransaction><!--- Begin is implied --->
> <cftry>
> <cfloop>
> ...DB Inserts here...
> </cfloop>
> <cfcatch type="Database">
> <cftransaction action="rollback"/>
> </cfcatch>
> </cftry>
>
> </cftransaction><!--- Commit is implied --->
>
> Provided you want all inserts to be performed or none at
> all...otherwise you need to adjust where the loop is etc.
There's no need to have a CFTRY/CFCATCH just to rollback, either - if
any
query fails, the entire transaction will rollback automatically. You
only
need to use ACTION="COMMIT" or ACTION="ROLLBACK" within a CFTRANSACTION
tag
if you want a partial commit or rollback.
<cftransaction
isolation="a_level_that_will_be_safe_for_your_transaction">
<cfloop>
... DB inserts here ...
</cfloop>
</cftransaction>
Dave Watts, CTO, Fig Leaf Software
http://www.figleaf.com/
voice: (202) 797-5496
fax: (202) 797-5444
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription:
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Get the mailserver that powers this list at http://www.coolfusion.com
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4