Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Abort a query
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Miscellaneous
Thread ID:
00711435
Message ID:
00711472
Views:
4
>Hi,
>
>After the users hit a button that causes the program tostart executinbg a query, can I abort the query before it completes, without aborting the program itself?
>
>For example, if the I find that the query is taking for ever to complete execution, can I just press say the 'ESc' key and abort the query and also the program back to the Search screen, so that I can start another query.
>
>thank you.
>
>Ria

Yes, once the query window appears, you can interrupt it by pressing ESC. Here is the code from our Querier class written by Mike Asherman:
private querhalt
* support user Escapes for interrupting query processing
		prevonesc = on('escape')			&& save previous Escape handler
		prevescape = set('escape')			&& previous Escape enablement state
		set escape on						&& enable escape handling
		querhalt = .f.						&& allow loop to run until this flag is toggled
		on escape querhalt = .t.			&& force immediate termination if user escapes

select ...
* restore temp settings changed surrounding query
		set talk off						&& in case the next line would otherwise cause TALK output
		set talk &prevtalk					&& restore original verbosity setting
		endtime = seconds()					&& stop query elapsed time computation
		on escape &prevonesc				&& restore previous Escape handler
		set escape &prevescape				&& restore previous Escape enablement
		this.EHP_TrapErrors = .f.			&& relinquish responsibility for err checking
		this.qryp_tally = _tally			&& hold on to the count of records selected
		this.QryP_Elapsed = m.endtime - m.starttime		&& elapsed time, in seconds
If it's not broken, fix it until it is.


My Blog
Previous
Reply
Map
View

Click here to load this message in the networking platform