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!

Locking of a single record (row) while being displayed. 2

Status
Not open for further replies.

arcangel

Programmer
Aug 2, 1999
6
US
I'm having problems with a MULTI-USER application that requires constant update of customers' information. I need to LOCK a record while the information is being updated on the screen so other users cannot access it. Upon submition, I want to update the table and UNLOCK this record.<br>
Can someone please tell me how this can be done?
 
use another table reason_table<br>
<br>
whenever pple want to update it...<br>
it will first write to the table ...<br>
<br>
when other user who want to update data,<br>
the system will check this table first ...<br>
if there exist record that tells u that...<br>
<br>
they will not be able to edit...
 
Another way is to put a column into the table which either<br>
<br>
1. identifies the user that has it locked<br>
2. simply has LOCKED/NOT LOCKED states (can be achieved with boolean or char(1))<br>
<br>
Then when you edit, you simply set the state of that column to locked, and on update, remove the lock.<br>
<br>
Don't forget, you need a clean up routine which somehow removes locks from the table if they have been there for a while? (expire the locks) You might find that using option 1 to lock the table is better, as you can then say that a single user can only ever have one row locked a time. IN which case, any time they edit an item, it removes any of their other locks.<br>

 
That extra column could also be a date/time column.<br>
<br>
With this, you could check to see if a record lock is older than a certain date (maybe an hour?). If it is, it is editable. To remove the lock upon an update, just set the date further back than your time-out.<br>
<br>
Also, to track if a record has EVER been edited, you could initialize the column with one date (like Jan 1, 1990) then use a different date (like Jan 1, 1991) when you force a time-out. This way, you will be able to see:<br>
<br>
Any record that is Jan 1, 1990 has never been edited.<br>
<br>
Any record that is Jan 1, 1991 has been edited.<br>
<br>
Any other date means someone selected the record and let their editing session time out.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top