Abort stored procedure execution

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
ricnogueira
Posts: 2
Joined: Tue 03 Jan 2012 14:53

Abort stored procedure execution

Post by ricnogueira » Tue 03 Jan 2012 16:14

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

AndreyZ

Post by AndreyZ » Wed 04 Jan 2012 12:01

Hello,

Please specify the provider (TUniConnection.ProviderName) you are working with.

ricnogueira
Posts: 2
Joined: Tue 03 Jan 2012 14:53

Post by ricnogueira » Wed 04 Jan 2012 12:52

AndreyZ wrote:Hello,

Please specify the provider (TUniConnection.ProviderName) you are working with.
I m working with SQL SERVER 2008

AndreyZ

Post by AndreyZ » Wed 04 Jan 2012 15:17

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.

Post Reply