How do I execute a "fire and forget" Oracle stored procedure in ODP.Net?

154 views Asked by At

I'm trying to resolve a thread blocking issue in an API that calls an Oracle DBMS's dbms_snapshot.refresh stored procedure. It is very long running in this case.

The existing code has what you might expect:

await cmd.ExecuteNonQueryAsync();

If this were a T-SQL DBMS, the command object would have a cmd.BeginExecuteNonQuery() method that would fire off the stored procedure without waiting for a return value. In ODP.Net's OracleCommand equivalent, this method does not exist.

How can I make the same call, but without the application parking and waiting for a return value?

Note: The DB is handled by a separate department; this must be a c# solution.

1

There are 1 answers

0
nvoigt On

Compared to the "Begin..." call, you could just remove the await

cmd.ExecuteNonQueryAsync();

That is the equivalent of the "Begin..." pattern call. However, neither is actually "fire & forget", because if you close the database connection and cancel the transaction, I guess the database will stop and roll back. So, you still need to "fire & wait", you are just free to do so asynchronously.