Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Zap/Dele All - no packing
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows 7
Database:
Visual FoxPro
Application:
Desktop
Divers
Thread ID:
01632301
Message ID:
01632328
Vues:
57
Guess you could add this at the top of that too...

IF USED('Bookings')
USE IN Bookings
EndIF


>There's some ambiguity in his code sample - SELECTed work area not 100% certain, also checking ISEXCLUSIVE() after trying the commands that require it. My code clears up those issues, he should run it in his environment as a test.
>
>Actually, if he can't get exclusive access, USE ... EXCLUSIVE should fail. So something like this might be better:
>
>SET SAFETY OFF
>
>TRY
>  USE Bookings IN 0 EXCLUSIVE
>
>  TRY
>    ZAP IN Bookings
>
>  CATCH
>    =MESSAGEBOX( "Unable to ZAP Bookings table" ) && This should never be reached
>
>  ENDTRY
>
>CATCH
>  =MESSAGEBOX( "Unable to open Bookings table EXCLUSIVEly" )
>
>ENDTRY
>
>SET SAFETY ON
>
>
>Also there are some other conditions that might affect this:
>
>- the table in use in another work area via something like USE Bookings IN 0 AGAIN ALIAS Bookings2
>- the table has been implicitly opened by being used in a FILTERed cursor, or a view
>
>The use of the table to power a grid also raises questions. Does the grid have any events that might fire if its data are changed? What if grid data are changed but not committed?
>
>I guess we should also ask if there's any chance the EXE has a Bookings.DBF included in the EXE (inadvertently or otherwise) :-\
>
>>ZAP is for sure a lot faster - but he's not able to get exclusive use of the table for some reason - so until he gets around that he's kinda stuck.
>>
>>How about:
>>>
>>>SET SAFETY OFF
>>>SET EXCLUSIVE on
>>>
>>>USE bookings IN 0 EXCLUSIVE &&I have tried it with and without the exclusive clause. Makes no difference.
>>>* USE ... IN 0 is good practice but be aware the table may not be opened in the current work area
>>>* unless there is no table open in it already
>>>* In fact, even if the current work area is empty, if there is a lower-numbered one also empty
>>>* it will be used instead
>>>* After a USE .. IN 0 command, either:
>>>* Follow it with SELECT Bookings, or
>>>* Use the IN clauses in commands to make sure you're working with the correct alias (e.g. ZAP IN Bookings below)
>>>
>>>IF ISEXCLUSIVE( "Bookings" )
>>>  ZAP IN Bookings
>>>  * DELETE ALL
>>>  * PACK
>>>
>>>ELSE
>>>  MESSAGEBOX('Not opened exclusively')
>>>
>>>ENDIF
>>>
>>>SET EXCLUSIVE OFF
>>>SET SAFETY ON
>>>
As Help says, "Issuing ZAP is equivalent to issuing DELETE ALL followed by PACK, but ZAP is much faster."
>>>
>>>If the above doesn't help:
>>>
>>>- Is Bookings a table, a cursor, or a view?
>>>- PACK creates temporary files, so you need read/write privileges to your temp files folder ( SYS( 2023 ) ).
>>>- If you're running real-time antivirus scanning, you could try temporarily disabling it, or excluding the folders containing Bookings.* and your temp files
>>>- Where are the Bookings.* files stored? Some low-end NAS boxes don't fully or properly support NetBIOS locking mechanisms so you can get unexpected results with EXCLUSIVE use and other commands that rely on it
ICQ 10556 (ya), 254117
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform