Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to verify table can be opened exlcusive
Message
General information
Forum:
Visual FoxPro
Category:
Other
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01192195
Message ID:
01192222
Views:
16
>>>Hi, I need to run a scheduled mainteance routine to reindeix all the tables after operating hours. I need to use the table exclusively in order to reindex. I have problem knowing whether the table has been used by user before issuing the command "use mytable exclusive".
>>>
>>>Any suggestion?
>>>
>>>Thanks
>>>
>>>james
>>
>>The simplest solution would be TRY and CATCH. I don't remember whether that was introduced in VFP 8 or 9; for older versions, use ON ERROR.
>
>VFP8 :-)
You can use on error like this:

local llCanProceed,lcOldErr
lcOldErr=''
lcOldErr=on('error') && buffer old error routine
on error llCanProceed=.f.
llCanProceed=.t.

*- now try to open table
use lcTable excl
if not(llCanProceed)
=messagebox("Please close Table: lcTable",64,"CANNOT PROCEED")
else
*- do what you need to do, because table is now open exclusively
endif

*- Now set error routine back to what it was prior to call
if not empty(lcOldErr)
on error &lcOldErr
else
on error
endif

HTH,
Mike
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform