Hi,
We have search functionality in our app, customer use it usually very nicely but sometimes they enter searchterms which cause query to run very longtime and they wan't to cancel it.
Since queries are blocking, it can't be terminated.
This idea sounds ugly, but in separete test app it works:
Create a separete Uniconnection and Uniquery
Pass them to iTask, which runs actual query.
If users wan't to cancel task, call uniconnection.disconnect, catch exceptions. Free components.
I feel this sounds dangerous / can cause un expected behaviour, but is is dangerous?
I'm using Actian ZEN with ODBC.
stopping a long running query
Re: stopping a long running query
Hi Mika,
Thanks for contacting us!
Please be informed, that there is no danger in canceling the select request.
For example, if you want to limit the request by time, you can use the "CommandTimeout" option.
Example:
You can find the description of the "CommandTimeout" option and other ODBC-specific options via the link: https://docs.devart.com/unidac/using-odbc-provider.htm
In case if you want to give the user the ability to cancel a long running request, you can alternatively try doing it on a separate thread.
Thanks for contacting us!
Please be informed, that there is no danger in canceling the select request.
For example, if you want to limit the request by time, you can use the "CommandTimeout" option.
Example:
Code: Select all
...
try
...
UniQuery.SQL.Text := 'SELECT ...'; //some big SQL query
UniQuery.SpecificOptions.Values['CommandTimeout'] := '60'; time is in seconds
UniQuery.Open;
...
except
On E: EUniError do
begin
//some exception handling logic
...
end;
...
end;
...
You can find the description of the "CommandTimeout" option and other ODBC-specific options via the link: https://docs.devart.com/unidac/using-odbc-provider.htm
In case if you want to give the user the ability to cancel a long running request, you can alternatively try doing it on a separate thread.
Re: stopping a long running query
Thanks for answer!
Command timeout helps a lot.
Command timeout helps a lot.
Re: stopping a long running query
Hi,
You're always welcome!
Please feel free to contact us if you have any further questions about our products!
You're always welcome!
Please feel free to contact us if you have any further questions about our products!