There was a recent posting on the houseoffusion cf-talk board about the use of cftransaction and cflock. Rather than reposting the entire thread here, you should just read it. It’s pretty interesting how there can be so many views on what the best way is to go about ensuring there are no database collides due to multiple users hitting the same database at the same time. I for one can say that I have always trusted cftransaction to handle this.
I’ve never worried about cflocking something because I’ve always felt that this should be handed off in a cftransaction block to the database so that database can do what it’s designed to do. There are real world chances that your database can be accessed from more than just ColdFusion. This means that even if you ensure there are no collides with coldfusion, you still have to worry about the database handling it all if the database can be called by more than just the coldfusion application.
I have written dozens of applications over the years of which some have thousands of database calls each day and I have never experienced any database collisions. I used CFTRANSACTION around any database calls when I’m inserting and extracting the latest ID and I’ve never cflocked it. It seems that my theory is supported by a few while other whole heartedly disagree with this simple approach.
Here is the House Of Fusion thread
Vince Collins