F
F
fmj2018-12-20 17:01:00
Oracle
fmj, 2018-12-20 17:01:00

How to interrupt the execution of a stored procedure while using OracleDataReader?

There is a client in c#, connects to the oracle subd via ODP.NET Managed. Cancellation of commands works, but if the execution reaches the Read method of the OracleDataReader class, then it becomes impossible to interrupt the execution. The stored procedure is executed for about 30-40 seconds (a report is built), if the cancellation request occurred before the call to the Read method of the OracleDataReader class, then everything is normally canceled. Forced closing (call of the close method) OracleDataReader, commands and connections (oracleconnection) does not help. It turns out that the actual execution of the query starts only when you try to read the data, because if in the stored procedure you first save all the data in the nested_table, and then return the ref cursor to the application from it, then everything is normally canceled, but it is very inconvenient to implement (and probably not very efficient).

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
d-stream, 2018-12-20
@d-stream

It turns out that the actual execution of the query begins only when you try to read the data
Simply oracle receives request, thinks and then already starts to issue the data.
While he is thinking - the reader is "hanging" in anticipation ...
By the way, why not drive a piece of data mining into a background thread and either bang it on cancellation, or just forget ...?

L
lam0x86, 2018-12-21
@lam0x86

OracleDataReader has asynchronous method variants. You can call ReadAsync instead of Read and pass your CancellationToken there.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question