Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Proper locking syntax for database

Status
Not open for further replies.

siituser

Programmer
Sep 30, 2002
67
CA
I have a question regarding proper naming syntax when doing a cflock.

I have been creating locks this way

example <cflock name="new_lock_name" type="readonly" timeout="15"> UPDATE/INSERT QUERIES </cflock>

1. Can the name be an actual word or is it better to use a unique lock for every lock instanse. ie. #cfid##cftoken#

2. When do you use exclusive locks as opposed to readonly.

Thanks
 
I don't like using the name attribute much.. it will only block other locked queries that use the same name.. so if you have 2 queries that read/write to the same table, but lock with different names, you can still step on each other's process.. I prefer to use application level locking

As for readonly versus exclusive, you can have multiple simultaneous readonly locks on the same query, but only a single exclusive lock.. so use readonly if you're only doing a select query and want to make sure someone doesn't write data at the exact time that you're reading (although if someone else wants to read while you're reading, that's fine), and use exclusive if you're writing data, and you don't want anyone to try to read while you're writing.
 
scope="application"?

That will only lock the application scope of variables, since they are shared.




 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top