Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Exclusive Table on Network 1

Status
Not open for further replies.

ezpzjohn

Programmer
Jun 29, 2001
50
GB
Hi

When using a table on a network is there any way that I can check if the table is already being USEd by another user before I try to open it?

For example, to carry out housekeeping by PACKing a table to get rid of deleted records, I want to open the table for EXCLUSIVE use. If the table is already opened by another user I get an error when I try to USE it EXCLUSIVEly. Is there a way I can check this before trying to USE the table?

John
 
Hi
IF USED(myTable)
** The Table is open now
ELSE
** It is not used now
ENDIF

OR
lUsed = USED(myTable) && lUsed is .t. or .f.
ramani :-9
(Subramanian.G),FoxAcc, ramani_g@yahoo.com
 
Try this:

ON ERROR WAIT WINDOW "Someone has the table open" TIMEOUT 3
USE SomeFIle EXCLUSIVE
ON ERROR

Dave S.
 
John,
Actually, just like when trying to find out whether a record is locked and you have to do RLOCK(), opening a file EXCLUSIVE is similar - you have to try.
Code:
* save off current error handler
lcSvError = ON("error")
llNoProblem = .T.
ON ERROR llNoProblem = .F.
USE myfile EXCLUSIVE
* set it back to normal error handling
ON ERROR &lcSvError 
IF llNoProblem
  MESSAGEBOX("Got file opened EXCLUSIVE")
ELSE
  MESSAGEBOX("File is in use")
ENDIF
Sorry, ramani, this time your code just won't accomplish what's needed. (I've gotten my share of answers wrong too :)).

Rick
 
Hi Rick..
Little more enlightenment required.
I tried the codes myself, and I am getting correct
myTable below.. need to be a Character variable.. so to say... if Test.DBF then... USED("TEST").. This is giving .t. or .f. in my testing.

IF USED(myTable)
** The Table is open now
ELSE
** It is not used now
ENDIF

OR
lUsed = USED(myTable) && lUsed is .t. or .f.
ramani :-9
(Subramanian.G),FoxAcc, ramani_g@yahoo.com
 
HI
stumped !!!!!!!!!!!!!!!!!!
I understand.. this is a network situation.. opened by some one else. Not the same user...
You are right Rick.. My answer is not correct. :-(
Thanks for pointing out.
ramani :-9
(Subramanian.G),FoxAcc, ramani_g@yahoo.com
 
That's OK, as you might guess the reason I knew that answer is that I'd been burnt by it before. Experience is a great teacher - it just "laughs" at you more than most of the helpful people here.

Congratulations on your "TipMaster of the Week" nomination - you deserve it.

Rick
 
Thanks to everyone for their suggestions, especially Rick whose suggestion works fine!

I smiled to myself when I read Ramani's first suggestion as I realised he had missed the network part - although I am still always pleased to see a response from Ramani as he is a great help in sorting out everyone's problems!

John
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top