> Can any one tell me how to lock a record in the table > for some time. > > When One record is opened for writing through a form, I > don't anyone else to open that particular record. I don't > know at which level this should be done either at Database > level or in ColdFusion.
The short answer is, you can't, and you really don't want to be able to do that anyway for various reasons. The problem you're trying to solve is a concurrency problem, but it doesn't lend itself well to a locking solution. Instead, you might use a simple timestamp solution - add a field to the record to track when it was last changed, and check the field's value before allowing a user's changes to be accepted. If the value is different than it was when the user first selected the record for editing, you know it's been changed since then, and you can address that various ways in code. In most CF applications I've seen, the developers have simply ignored concurrency issues with multiple editors, which isn't really a good idea, but locking the database to prevent it would be even worse, since there's no "persistent connection" between the browser and the database. However, implementing the timestamp model described above is pretty trivial - I've done it in fifteen minutes or less in classrooms for student demonstrations. Dave Watts, CTO, Fig Leaf Software http://www.figleaf.com/ voice: (202) 797-5496 fax: (202) 797-5444 ______________________________________________________________________ Structure your ColdFusion code with Fusebox. Get the official book at http://www.fusionauthority.com/bkinfo.cfm FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists