Blog Post RSS ?

Blogs » ColdFusion » DB Transactions With ColdFusion
 

DB Transactions With ColdFusion

by davidjmedlock

…posted by davidjmedlock:

Time flies all too quickly. I’ve been remiss in my posting here and I apologize. I did plan to write a quick note about the security of scheduled tasks, but I have yet to figure out a solid way of authenticating who ever is accessing them. At any rate, I did find this excellent article on Macromedia regarding database transactions.

For anyone who has ever developed serious applications, you may have encountered times when you performed many database alterations all in a row only to have one of them fail and ultimately ruin your afternoon (or weekend, even…) I strongly encourage the use of transactions as a means of error handling in your application. And in ColdFusion, they’re extremely easy to use.

With a framework such as .Net, you have to create a transaction object and attach it to a connection object and then begin the transaction and then when you’re finished with your queries, you have to commit the transaction. If you fail to do everything in just the right manner, you’re application will explode. With ColdFusion it’s really quite simple:

If any query inside the tag were to bomb at any point, all the queries would be reversed, including any update, delete, or insert actions you had previously performed. I’ve used this many times in my applications and trust me, it can save you a lot of headaches. This also helps if the queries you run tend to be numerous or very bulky and put your application in peril of timing out, which I’ve had happen a few times.

So, there’s a little something more for your error handling and overall application stability toolbox. Enjoy.

Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Ping.fm
  • Twitthis

Related posts:

  1. ColdFusion 9: Why You Should Pay Attention (Yes, You!) It’s fun being in this business—there are so many new,...
  2. Rate Your Stuff with ColdFusion Our latest ColdFusion tutorial covers how to add a simple...
  3. Can You Get Manipulative? Take This ColdFusion Quiz and Find Out! We've just published a new quiz and tutorial on manipulating...
  4. The Future of Flash and the Return of ColdFusion With 46 sessions over two days, the recent WebDU conference...
  5. MySQL: the Pros and Cons of InnoDB Tables Craig discusses why the lesser-used MySQL InnoDB table engine might...

This post has 4 responses so far

Sponsored Links

SitePoint Marketplace

Buy and sell Websites, templates, domain names, hosting, graphics and more.

Follow SitePoint on...