How to check if record is locked (again)

I submitted this question a couple of days ago:

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.

and got this response from Waldek:

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}

The code doesn't compile and I was wondering if Waldek, or anybody who gets this, could help me out again?
The following code works but will report the same error when ANY kind of EDBEngineError Exception occurs. Can you tell me (or even better, 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);
    except on EDBEngineError do
      showmessage('Record is locked !');

I want to know how I can extract the specific error condition that has occured.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Sorry , in program You must use BDE function DBIIsRecordLocked(hCursor:hDBICur; var bLocked: Bool) if bLocked is set to true then record is locked. Greeting

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
tdiamondAuthor Commented:
I found it but I'm having a little trouble implementing it correctly.  Could you possibly give me an example of how it might be called and with what parameters?  For instance, here is what my code lookes like:

procedure TFRMMain.ButtonClick(Sender: TObject);
  b: bool;
  DbiIsRecordLocked(ItemsTable.handle, b);
  if (b=true) then
    showmessage('Record IS locked')
    showmessage('Record is NOT locked');

It compiles, but when it runs, it always reports the record NOT being locked even when it is!  Can you tell if I'm doing something wrong in my code.  Am I passing the correct parameters?
Check this
var b: bool;
  Check(DbiIsRecordLocked(ItemsTable.handle, b));
     if b then
       showmessage('Record IS locked')
       showmessage('Record is NOT locked');
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.