Solved

How to check if record is locked

Posted on 1997-12-04
3
191 Views
Last Modified: 2010-04-04
How can you check to see whether a record that you are about to write to is locked by another user?  If I have to check for an exception, then which one should I check for (EConvertError, E....)?  What I want to do is rollback a Transaction if my write to a table fails.
0
Comment
Question by:tdiamond
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 2

Accepted Solution

by:
Waldek earned 100 total points
ID: 1352908
You must check for exception EDBEngineError and then
test ErrorCode like this
 case Errors[0].ErrorCode of
  DBIERR_LOCKED:{ Action , if lock failed}
  DBIERR_UNLOCKFAILED: { Action , if unlock failed}
 end;
0
 

Author Comment

by:tdiamond
ID: 1352909
What you gave me is a great start but it doesn't seem to compile (unless I'm doing something wrong). The following code works but will report an error when any kind of EDBEngineError occurs.  Can you tell me (or show me) how to modify it to test specifically for a locked record?  It would help me out a lot.

procedure TFRMMain.Button2Click(Sender: TObject);
begin
  try
    ItemsTable.edit;
    ItemsTable['Test']:=1;
  except on EDBEngineError do showmessage('Record is locked !');
  end;
end;
0
 
LVL 2

Expert Comment

by:Waldek
ID: 1352910
check function from unit BDE : DBIIsRecordLocked
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Delphi - replicating a form 8 93
Magic Software info 18 144
Tvertscrollbox like a whatsapp layout delete messages 1 39
Add New Database Table in database file using delphi 3 32
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question