tags:

views:

77

answers:

4

We are using oracle > 10.0 here and our software creates different types of reports for evaluation of the stored data. Because of the amount of data it is possible that such a report takes a couple of minutes to create and the customers would like to stop the queries.

Is there a way to say the DMBS that it should stop a query? It would also be great to get state information like a count of rows allready read.

+2  A: 

According to a blog post from Tanel Poder here, a call to DBMS_RESOURCE_MANAGER.SWITCH_CONSUMER_GROUP_FOR_SESS (sid, serial#, 'CANCEL_SQL'); (where sid and serial# identify the session to be interrupted) may work, but he's not tested it.

If your application can make OCICancel() or jdbc Statement.cancel calls, that may work as well.

In either case, I'm not sure how to get a state of rows already read; interrupting a SQL*Plus session that's spooling output will tell you how many rows it has output, but if it hasn't started spooling output, it won't.

Adam Musch
+1 for the link to Tanel's post - I'm going to experiment with this myself, as this could be very useful.
dpbradley
A: 

If you can define a cut-off time (or other resource) limit for the queries, set up Oracle profiles and resource limits and let the RDBMS take care of killing the sessions: doc here

dpbradley