Page 1 of 1
Abort stored procedure execution
Posted: Tue 03 Jan 2012 16:14
by ricnogueira
Is there any way of aborting a stored procedure (TUniStoredProc) or query (TUniQuery) that is taking too long to run? I want to set up a kind of timeout, so if the sp / query doesnt return in X seconds I want to abort it
Posted: Wed 04 Jan 2012 12:01
by AndreyZ
Hello,
Please specify the provider (TUniConnection.ProviderName) you are working with.
Posted: Wed 04 Jan 2012 12:52
by ricnogueira
AndreyZ wrote:Hello,
Please specify the provider (TUniConnection.ProviderName) you are working with.
I m working with SQL SERVER 2008
Posted: Wed 04 Jan 2012 15:17
by AndreyZ
You can use two approaches:
- set the CommandTimeout specific option to X seconds. CommandTimeout determines the amount of time that expires before an attempt to execute a command is considered unsuccessful. It is measured in seconds. Here are examples of setting CommandTimeout:
Code: Select all
UniStoredProc.SpecificOptions.Values['CommandTimeout'] := '20';
UniQuery.SpecificOptions.Values['CommandTimeout'] := '20';
- call the BreakExec method. BreakExec breaks execution of the SQL statement on the server. You should call BreakExec only from another thread. Here are examples of calling BreakExec:
Code: Select all
UniStoredProc.BreakExec;
UniQuery.BreakExec;
For more information, please read the UniDAC documentation.