Board index » delphi » To TQuery.Edit, or not to TQuery.Edit

To TQuery.Edit, or not to TQuery.Edit

Hello all
I am using Delphi 3.02 C/S, SQL Server 6.5.
I have heard conflicting opinions from a number fo Delphi developers
regarding the use of the Edit method. I have been told that locking a
record when a user starts to make changes to it is a bad design because it
stops others from editing the record. I personally think the opposite, I
think a record SHOULD be locked when a user starts to make changes so that
no one else can make changes while you are.
Unfortunately, on SQL Server locks performed by other users are not being
seen (I know SQL Server only supports page locking). I was not aware of
this when I first started development using SQL Server, and I had to
implement a temp locking mechanism to get around the 'problem'.
I have been told that the 'good' design requires the developer to check to
see if the record has changed before posting any changes. This does not
seem correct to me, but I am open to discussion from both sides.
SQL Server 7 supports record level locking, so does that mean that I am
correct in that locking a record at the start of an Edit is correct, or am
I wrong?

John Hair
Designer Systems Ltd


Re:To TQuery.Edit, or not to TQuery.Edit

The problem with locking and waiting on user update is that the record
remains locked until the user (who may be out to lunch) grants the update.
Yes, you can create some arbitrary timing technique or so on if you desire.

We have a system which has automated processes for various things occurring
all the time.  If a user was allowed to LOCK the record or page for any
length of time, then the automated processes would have to wait until the
user unlocked the record or page before it could continue processing.

We prefer to abort the edit if in the time the user has begun changing the
record and the time he finishes and the record was changed by another user
before he finished.

just my .02
Charles Lam

Other Threads