Solved

How to check if record is locked

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

ScreenConnect 6.0 Free Trial

Discover new time-saving features in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

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

Suggested Solutions

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

770 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