interrupt oracle query with Oracle data access client

151 Views Asked by At

I want to kill oracle query after 10 mins of its execution through c#, I achieve it by using Oracle.ManagedDataAccess.Client.dll, but my existing project is using System.Data.OracleClient.dll in which cmd.CommandTimeout is not updating on runtime see here. I searched alot but couldn't find anything, Its not logical to switch to new dll on which whole project is relying. Is there anything that can be done to update/set CommandTimeout in System.Data.OracleClient.dll. Below code is with System.Data.OracleClient;

string connString = "Data Source=xx; User ID=xx; Password=xx;";
var conn = new OracleConnection(connString);
var cmd1 = new OracleCommand(cmdString1, conn);
                  
cmd1.CommandTimeout = 6;

conn.Open();

try
{
    cmd1.ExecuteNonQuery();
}
catch (Exception exception)
{
        
}

cmd1.CommandTimeout remains 0 even after code execution. Below is with Oracle.ManagedDataAccess.Client;

string connString = "Data Source=(DESCRIPTION=xxx); User Id=xx; Password=xx;";
                           
conn = new OracleConnection(connString);
var cmd1 = new OracleCommand(cmdString1, conn);
cmd1.CommandTimeout = 6;

conn.Open();

try
{
    cmd1.ExecuteNonQuery();
}
catch (Exception exception)
{
}
             

this code is killing the query but I cant use this dll.

0

There are 0 best solutions below