Check for Table Lock Under Vortext Windows

Post Reply
sroth
Posts: 44
Joined: Mon Jul 23, 2007 11:21 am

Check for Table Lock Under Vortext Windows

Post by sroth »

I don't see ltest for Windows. Is there a way to check a table for locks from with a vortex script?

I need to see another process is updating data in a temporary table before my main process continues.
User avatar
mark
Site Admin
Posts: 5519
Joined: Tue Apr 25, 2000 6:56 pm

Check for Table Lock Under Vortext Windows

Post by mark »

There's dumplock under windows. There's no other way to check for locks on a table. If some other process is performing inserts or updates the locks will come and go so it will be just as likely to see no lock as to see the lock. If you need to synchronize processes you should create and set your own semaphore of some kind. Possibly a file or a record in an auxiliary table.
User avatar
John
Site Admin
Posts: 2622
Joined: Mon Apr 24, 2000 3:18 pm
Location: Cleveland, OH
Contact:

Check for Table Lock Under Vortext Windows

Post by John »

There is a dumplock program that outputs the state of the locks in a usable manner.

I would not rely on the lock state to say if the other process is updating, as it may not have a lock at the moment you look at it. Can you tell by existence of the temporary table, or if there is a recent update?

E.g.

SELECT NAME FROM SYSTABLES WHERE NAME = 'TMPTABLE';

or

<SQL MAX=1 "SELECT id FROM TMPTABLE where id > '-1 minute'">
John Turnbull
Thunderstone Software
sroth
Posts: 44
Joined: Mon Jul 23, 2007 11:21 am

Check for Table Lock Under Vortext Windows

Post by sroth »

Looks like I'll have to set a flag in a table when the process starts, but how can I guarantee that the flag will be cleared even if the process aborts? I'd like something like a Try Catch Finally statement.
User avatar
mark
Site Admin
Posts: 5519
Joined: Tue Apr 25, 2000 6:56 pm

Check for Table Lock Under Vortext Windows

Post by mark »

You could store the process id in the table then lookup that pid in the dumplock output to see if it's still attached to the db.
Post Reply