Solved

How to check if record is locked

Posted on 1997-12-04
3
168 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
  • 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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

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…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
This video discusses moving either the default database or any database to a new volume.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

762 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now