Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 8 of 8 total
Thread Testing for a lock
Mon, Nov 15 2010 9:41 PMPermanent Link

ClockOn

is there a way to know if there is a transaction or table lock, rather than having to try and causing an exception?
Tue, Nov 16 2010 5:35 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

<< is there a way to know if there is a transaction or table lock, rather
than having to try and causing an exception? >>

No, and such a function really wouldn't be feasible because the only way to
test for such a lock is to attempt the lock, which is effectively what
you're doing with a try..except block anyways.

--
Tim Young
Elevate Software
www.elevatesoft.com
Tue, Nov 16 2010 4:41 PMPermanent Link

ClockOn

thanks tim thats what I thought, but wanted to just double check. You just never know...
Smile
Tue, Nov 16 2010 4:59 PMPermanent Link

Gregory Sebastian

Did you mean Database transaction ? If so there is one :
Database.InTransaction .

Regards
Gregory Sebastian


"ClockOn" wrote in message
news:486F7CD9-D54C-4CD0-81B3-E0BA49F7F74D@news.elevatesoft.com...
> is there a way to know if there is a transaction or table lock, rather
> than having to try and causing an exception?
>
Wed, Nov 17 2010 6:39 PMPermanent Link

ClockOn

Thanks Gregory, but as far as im aware that only works for the current session, if another session has a transaction then InTransaction does not work...
Wed, Nov 17 2010 11:54 PMPermanent Link

Gregory Sebastian

Hi Clockon,
<<Thanks Gregory, but as far as im aware that only works for the current
session, if another session has a transaction then InTransaction does not
work...>>
Yes I think its just for the current session/database .  If your
transaction/updates cannot be affected by other sessions, I think you must
attempt to Lock the table or open them exclusively.

<<is there a way to know if there is a transaction or table lock, rather
than having to try and causing an exception?>>
You could setup your own function like :

function TryToLockTable(TableToLock : TDbiSamTable) : Boolean;
begin
 try
   TableToLock.LockTable;
   result := True;
 except
   result := False;
 end;
end;

It will report to you on success or failure without raising an exception but
you still need to handle the failed lock attempt either way Smile.

Regards
Gregory Sebastian
Thu, Nov 18 2010 6:34 PMPermanent Link

ClockOn

Thanks gregory, I was wondering more so if the server tracked the status of the locks when in C/S mode really. Thanks for your help but, much appreciated...
Mon, Jan 3 2011 2:04 PMPermanent Link

Robert Kaplan


"Gregory Sebastian" <gregorys@nospam-ezysoft-dev.com> wrote in message
news:E85DD2CB-34E0-40F7-A600-178E9CBA5F99@news.elevatesoft.com...
>
> function TryToLockTable(TableToLock : TDbiSamTable) : Boolean;
> begin
>  try
>    TableToLock.LockTable;
>    result := True;

You need to unlock the table here if you want to leave eveything the way you
found it.

Robert

Image