----- Original Message -----
From: "Nesler, Thomas J" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Wednesday, April 26, 2006 2:06 PM
Subject: RE: [delphi-en] Using the TTable Edit Error Event
> What I am looking for is an example or two on how to handle deadlocks or
> other kinds of locks on a record.
>
> Tom Nesler
I prefer the method that Jangita has proposed: if the program is set up
well,
I think the amount of code can be reduced (using OOP and recycled functions
etc.);
Deadlocks should be difficult to set off (possibly due to complex stored
procedure or triggers
with secondary effects on other tables), though you can possibly handle this
kind of thing with transactions
and nested If clauses (if all functions go as expected then comit else
rollback);
If I understand your problem, you want to allow only one user to edit a
given record or record/field combination at a time:
one solution: create a 'booking' table with tablename, keyfieldname,
keyfieldvalue, userID, StartDateTime and Timeout: you can use it for
assigning or booking exclusive access to the table/record/field (it's not a
matter of protecting data integrity by locking);
If a table/record/field is present in the table then a second user will not
be allowed to edit it (you can inform them that the field is currently being
edited by another user: you can supply the userID or Terminal name etc.);
You can put a timeout on the field (otherwise the field will be marked as
'booked' for ever): the user will only be able to save altered data fields
within the timeout period (like on many Internet sites used eg for plane
Ticket reservation): the Server will need to delete timedout records every
so often using a timer;
Once editing is finished you can 'unbook the table/record/field' at which
point you can delete the record in the 'booking' table;
If you are interested in OOP you can develop a single 'booking' component
which will give you the basic functions:
BookRecordField('table1', 'f_id', 'client_id', 10 ); // reserves
record f_id=10/field 'client_id' in table1;
UnBookRecordField('table1', 'f_id', 'client_id', 10 ); // removes
reservation on record f_id=10/field 'client_id' in table1;
IsRecordFieldBooked('table1', 'f_id', 'client_id', 10 ); // returns True or
False to indicate whether it is booked;
It is really a system of software locking control at a level higher than
database locking,
and might be considered Multi User Task Control rather than database locking
proper:
the locking at db level conserving data integrity, whereas the 'booking' is
a form of validation
on the client side;
You can also use Status flag fields to limit what you can do to a record and
therefore to influence the level of editing if any that you can allow to a
user (RecordBooked, available, suspended etc.);
Kevin O'Neill
-----------------------------------------------------
Home page: http://groups.yahoo.com/group/delphi-en/
To unsubscribe: [EMAIL PROTECTED]
SPONSORED LINKS
| C programming language | Computer programming languages | Java programming language |
| The c programming language | C programming language | Concept of programming language |
YAHOO! GROUPS LINKS
- Visit your group "delphi-en" on the web.
- To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
- Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.

