Question
About CFTransaction
The classic example of using rollback and commit in this scenario is in an online banking system
that allows a user to transfer funds from one account to another. An obvious business rule in this
scenario is that a user cannot withdraw or transfer more money from an account than that account
contains. The code for transaction-based logic looks something like the following:
http://www.adobe.com/devnet/coldfusion/articles/cftransaction.html
<cftransaction> <cfquery name="qUpdAccount1" datasource="myDSN"> UPDATE Accounts SET accountBalance = accountBalance - #withdrawAmount# WHERE accountid = #accountID1# </cfquery> <cfquery name="qUpdAccount2" datasource="myDSN"> UPDATE Accounts SET accountBalance = accountBalance + #withdrawAmount# WHERE accountid = #accountID2# </cfquery> <cfquery name="qAccount1Balance" datasource="myDSN"> SELECT accountBalance FROM accounts WHERE accountid = #accountID1# </cfquery> <cfif qAccount1Balance.accountBalance lt 0> <cftransaction action="ROLLBACK" /> <cfelse> <cftransaction action="COMMIT" /> </cfif> </cftransaction>
I was tried above example about cftransaction but it is not working.Please provide any solution for this.
