I wish to ask if it is possible to stop an sql query during its execution. I wish to do this so that if someone else is executing the same query at the same time, the application would not jam. I am using visual studio c# as front end and oracle 11g as my back end
Check the status of the query using the SP_who2 command. After some time, use the KILL command to KILL SPID using the following command. Execute this command in a new query window. Once we execute the KILL SPID command, SQL Server starts the ROLLBACK process for this query.
SQL Server Management Studio Activity Monitor Scroll down to the SPID of the process you would like to kill. Right click on that line and select 'Kill Process'. A popup window will open for you to confirm that you want to kill the process.
Now pause SQL Server by right clicking on the server instance and selecting Pause. It opens up a pop-up window to confirm or cancel the pause operation. Click Yes to go ahead with the pause operation.
You can wrap the sql query in a pl/sql function and get a lock (with the dbms_lock package) before executing the select statement in the function/procedure (of course you have to release the lock at the end). This way you can serialize the execution of this function.
Another options is to use database jobs.
What query are you doing where this is a problem? Most likely that can be optimized to solve whatever issue you're having.
It's not really realistic to do this because for every query that comes in, you'll have to see if someone else is already running it first. That's going to create a lot of overhead and complexity in the system.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With