Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
File in use
Message
De
08/03/2003 13:41:30
 
 
À
07/03/2003 16:41:13
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Divers
Thread ID:
00762256
Message ID:
00763303
Vues:
15
Thanks Steve just what I needed - Isn't UT great!
Gaylen
>
>Here is a function that may help you out...it needs some better error handling on checking the destination location. This assumes that you can extract data to a temporary location first, and then copy over the current data. After extracting the data to temp file, and before beginning the copy process, you should do something that will display a message to any users that might try to run a query while the copy is in process.
>
>
>function copyfile
>lparameters lcSource, lcDestination, lnMaxTries, lnWait
>* lcSource:  name of source file
>* lcDestination:  name of destination file
>* lnMaxTries:  maximum attempts to copy file, defaults to 1 try
>* lnWait: time to wait between attempts, in seconds.  Defaults to 10 seconds.
>
>* need to add better parameter checking, such as on validity of lcDestination
>
>	local lcOldError, llSuccess, lnTries
>
>	if not file(lcSource)
>		error "Source file does not exist...cannot copy file."
>		return .f.
>	endif
>
>	if empty(lnMaxTries)
>		lnMaxTries = 1    && default number of tries
>	endif
>
>	if empty(lnWait)
>		lnWait = 10000    && defaults to 10 seconds between tries
>	else
>		lnWait = lnWait * 1000
>	endif
>
>	declare Sleep in Win32API integer nMilliseconds		
>
>	lcOldError = on("error")
>
>	lnTries = 0
>	llSuccess = .f.
>	on error llSuccess = .f.
>
>	do while not llSuccess and lnTries < lnMaxTries
>		lnTries = lnTries + 1
>		llSuccess = .t.
>		copy file (lcSource) to (lcDestination)
>
>		if not llSuccess and lnTries < lnMaxTries
>			=sleep(lnWait)
>		endif
>		
>	enddo
>
>	on error &lcOldError
>	return llSuccess
>
>endproc
>
>
>>Steve
>>I need to create an extract table of selected records from a larger data set for use on a web server. This will be done at midnight, kicked off by a timer. However there is a possibility(however remote) someone may be querying the data at the same time I am coping the new file over. In that case I want to keep checking until no one is using the file then overwrite the old extract file.
>>
>>I use a sql statement in the web page to grab only the data pertinent to that user from the extract file and then immediately close the extract file. My thinking is there is a remote possiblity of conflict, but I would like to provide for it.
>>
>>All this will be unattended.
>>
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform