I have an application that runs on the terminal
The terminal is registered on the database table is.
During all the sessions that run on the terminal, I need to make sure that the table on the terminal related to the terminal is locked
What is the best way to do this?
I use programming language and SQL Server as C # .NET as DBMS.
Thanks: D
Generally, I try to work with short-term locks Where I can do a full job unit of work in a single (serial) transaction; This avoids the need for an additional locking mechanism, since DB lock fulfills the requirements of everything.
While working with long-standing locks: It is a bad idea to use rdbms-locks for this purpose - it's not only on the scale, timestamp or row-edition column, accidental over- Optimistic is a good way to prevent concurrency from writing.
To publish / apply the fact that a line is being edited, I make the User-ID / Locking User's Username (if not locked) in a column Who is the owner of that line - that is, when you want to edit the row, first update it, set your user id (and make sure it is not already closed).
There are 3 general options for dealing with locks that are not properly removed (due to a dead terminal etc.):
- When lock owner re-logs Allow them to break their own locks <
- Allow an administrator to store a lock-timeout column (day-time), and the scheduled tasks will be automatically added to the rows Unblock the ones which are overdue
summarizing For some - like something to consider:
FU === ID ... data ... | Timestamp | Lock Owners | Locktimeout --- + ------------ + ----------- + ----------- + -------- ----
etc.
Comments
Post a Comment