I just need to post this as all examples I found were explaining how to use transaction in a <cftry> and <cfcatch> block with only one query.
But if you have a query file to include in your Fusebox application, that does multiple queries and only one needed to be in a transaction block, then the solution I found was the following :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | <cftry> <!---multiple queries---> <cfquery name="" datasource="">...</cfquery> <cftransaction action="Begin"> <cftry> <cfquery name="" datasource="">...</cfquery> <cftransaction action="Commit"> <cfcatch> <cftransaction action="Rollback"> </cftransaction></cfcatch> </cftransaction></cftry> </cftransaction> <cfcatch> <!---error messages---> </cfcatch> </cftry> |
I needed another <cftry> and <cfcatch> block inside the <cftransaction> block as I needed to rollback the transaction and catch the exception.
Hopefully this will save someone’s time as some solutions are so difficult to find in documentations or even form postings, mostly unanswered postings appear in the list which can only make you feel better that you’re not alone!