Abort stored procedure execution
-
ricnogueira
- Posts: 2
- Joined: Tue 03 Jan 2012 14:53
Abort stored procedure execution
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
-
ricnogueira
- Posts: 2
- Joined: Tue 03 Jan 2012 14:53
-
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:- 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:For more information, please read the UniDAC documentation.
- 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';Code: Select all
UniStoredProc.BreakExec;
UniQuery.BreakExec;