CFTRANSACTION tag is treated as a transactional unit. This means that changes made to the database are not committed until all queries in the transaction block execute successfully. If an error occurs in one of the queries, all changes made by previous queries within the transaction block are rolled back. |
<CFTRANSACTION> |
<CFQUERY NAME="WithdrawCash" DATASOURCE="BankDB"> |
UPDATE Accounts |
SET Balance=Balance - #Amount# |
WHERE Account_ID=#AccountFrom# |
</CFQUERY> |
<CFQUERY NAME="DepositCash" DATASOURCE="BankDB"> |
UPDATE Accounts |
SET Balance=Balance + #Amount# |
WHERE Account_ID=#AccountTo# |
</CFQUERY> |
</CFTRANSACTION> |