Solved

How to cancel Oracle query from VB.Net Windows Application

Posted on 2014-09-17
3
711 Views
Last Modified: 2014-09-29
I have a straightforward windows application written using VB.Net, Visual Studio 2010 using the Oracle Data Provider.

Sometimes Users issue queries that take a long time to process and would like to cancel the query.

I would like to display a button above a Datagrid that says "Cancel" and when clicked, abort the query and kill the User request with Oracle.  TOAD currently uses this functionality but I don't know how they do it.

Any code snippets would be greatly appreciated.
0
Comment
Question by:BISCO3
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 77

Expert Comment

by:slightwv (䄆 Netminder)
ID: 40328438
If you are using ODP.Net try:

OracleCommand.Cancel

http://docs.oracle.com/cd/B19306_01/win.102/b14307/OracleCommandClass.htm#DAFIEHHG

There is an example in that doc link.

If you aren't using ODP.Net, I would STRONGLY encourage you to start.
0
 

Author Comment

by:BISCO3
ID: 40331433
That's good for a scalar command but what about cancelling a Fill operation on a Data Adapter?
0
 
LVL 77

Accepted Solution

by:
slightwv (䄆 Netminder) earned 500 total points
ID: 40331640
I'm not a .Net guy.  I'm an Oracle DBA that knows enough .Net to be more than a little dangerous.

I think you have officially exceeded my .Net abilities!

That said:
1:  I found the link below that is likely a SQL Server solution but the commands should port to ODP.Net pretty easily:
http://social.msdn.microsoft.com/Forums/vstudio/en-US/ad4f5811-a08d-4342-bcf1-368ceac834fc/is-there-any-way-to-cancel-a-dataadapterfill-command-while-its-processing?forum=csharpgeneral

2:  A DBA tends to provide database centric solutions.  I beleive you can limit the execution time with resource management but I've never played with any of this:
http://docs.oracle.com/cd/E11882_01/server.112/e25494/dbrm.htm#ADMIN11857

3: Tag the select that is used in the fill with a unique 'comment':
select /* UNIQUE_COMMENT_1234567890 */ sysdate from dual;

Then on the app side, find the sid and serial# (for example, 1 and 123) of that exact select statement and execute the following SQL:
alter system kill session '1,123';
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Cursors in Oracle: A cursor is used to process individual rows returned by database system for a query. In oracle every SQL statement executed by the oracle server has a private area. This area contains information about the SQL statement and the…
Shell script to create broker configuration file using current broker Configuration, solely for purpose of backup on Linux. Script may need to be modified depending on OS-installation. Please deploy and verify the script in a test environment.
This video explains at a high level with the mandatory Oracle Memory processes are as well as touching on some of the more common optional ones.
This video shows information on the Oracle Data Dictionary, starting with the Oracle documentation, explaining the different types of Data Dictionary views available by group and permissions as well as giving examples on how to retrieve data from th…

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question