Cancellable queries

wftjeremy

Member
I have gone through all of the examples I can find for cancellable queries... still can't get it to work.

What I have is simple. I have a button that decides if entries in a memo field is a select statement or not. If it isn't a select statement the query is passed to a toraclescript and ran with the feedback being passed into another memo.

If the query is a select statement the query is then passed into a toracledataset and ran, with the output being put into a DBgrid so the users can edit the data, export to a file etc.

What I want to do is simply this - Have the CANCEL button actually cancel whatever is running. I can't figure how to cancel either the toraclescript OR the toracledataset.

Help!
 
You should probably set TOracleDataSet.QueryAllRecords to False, open it in a background thread (so that the main thread can process the button-press), and connect it to a datasource after it is opened.

The main thread can call TOracleSession.BreakExecution when the button is pressed.

If I have some time I will create a little demo and post a link here.

------------------
Marco Kalter
Allround Automations
 
Originally posted by mkalter:
The main thread can call TOracleSession.BreakExecution when the button is pressed.

What if the session has multiple queries hooked into it? If BreakExecution stops all currently running queries (possible in a multithreaded system), but we're only interested in stopping one, how would one go about handling that?

Or does TOracleSession only handle one query execution at a time? Even in that case, you could have one query running right after another one, and have the user not knowing which query they are stopping.

Thanks,
Steve
 
stevemagruder:

A session can indeed execute just one query at a time, so calling BreakExecution is not unambiguous.

wftjeremy:

I will publish a little demo that allows you to cancel a TOracleDataSet query tomorrow.

------------------
Marco Kalter
Allround Automations
 
You can download a little (Delphi) demo of a cancelable TOracleDataSet here . The code should be self-explanatory.

The application allows you to enter and execute a query, and to cancel execution. If the dataset has already fetched records when the Cancel button is pressed, a truncated result set will remain.

I hope this helps.

------------------
Marco Kalter
Allround Automations
 
Back
Top