• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 29. More About SQL and Queries > Using Database Transactions

Using Database Transactions

ColdFusion provides a tag called <CFTRANSACTION>, which can be used to explicitly specify the beginning and end of a database transaction. A database transaction is a way of telling your database system that several SQL statements should be thought of as representing a single unit of work.

For instance, in the Orange Whip Studios project, the series of related inserts that need to occur to record a merchandise order should be thought of as a single transaction. An order really hasn't been properly recorded unless the appropriate records have been added to both the MerchandiseOrders and MerchandiseOrdersItems tables. During the moments between those inserts, the database is in what's called an inconsistent state, meaning that the data doesn't properly represent the real-world facts yet. Database transactions ensure that your database doesn't expose this inconsistent state to other connections.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint