Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
File in use
Message
From
07/03/2003 16:41:13
 
 
To
06/03/2003 19:51:04
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Miscellaneous
Thread ID:
00762256
Message ID:
00763035
Views:
18
This message has been marked as the solution to the initial question of the thread.
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.
>
Steve Gibson
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform