cftransaction

Instructs the database management system to treat multiple
database operations as a single transaction. Provides database
commit and rollback processing.

 <cftransaction>

 transaction { }

Attribute Reference for the cftransaction tag

action

Required: No
Default: begin

  • begin: the start of the block of code to execute

  • commit: commits a pending transaction

  • rollback: rolls back a pending transaction

Values:
  • begin
  • commit
  • rollback
  • setsavepoint

isolation

Required: No
ODBC lock type. Values:
  • read_uncommitted
  • read_committed
  • repeatable_read
  • serializable

savepoint

Required: No
The name of the savepoint in the transaction.

nested

Required: No
specifies whether transaction is nested or not

Examples sample code using the cftransaction tag


Script Syntax


transaction { 
 try { 
 // code to run 
 transaction action="commit"; 
 } 
 catch(any e) { 
  transaction action="rollback"; 
  } 
 }

Tag Syntax

<cftransaction> 
 <cftry> 
 <!--- code to run ---> 
   <cftransaction action="commit" /> 
 <cfcatch type="any"> 
 <cftransaction action="rollback" /> 
 </cfcatch> 
 </cftry> 
 </cftransaction>

Fork me on GitHub