I've been using the Oracle ODP.NET, Managed Driver to issue queries from C#.
There were many queries i wrote that took forever to return any data; like it was ignoring my row limiting clauses:
SELECT TOP 10 *
FROM Customers
or
SELECT *
FROM Customers
FETCH FIRST 10 ROWS ONLY
It was like Oracle was ignoring my 10 row limit, and started returning everything - because it was taking forever to return. Eventually i realized that it wasn't that the query was busy returning a lot of data; it was that the query SQL was invalid.
When you issue invalid SQL to Oracle, it will not fail with an error.
select top 10 * from customers;
select 'Hello, world!';
select sysdate from duel;
select sysdate fro;
Ceilings make pie and markers drive the ocean with their feet
Oracle will sit there waiting for the command timeout to expire.
IDbCommand cmd = connection.CreateCommand();
cmd.CommandText = "Ceilings make pie and markers drive the ocean with their feet";
IDataReader rdr = cmd.ExecuteReader(); //<--will wait forever
while (rdr.Read())
{
//...
}
I eventually realized that the Oracle.ManagedDataAccess.Client.OracleCommand
object (bizzarly) has no CommandTimeout
; it defaults to running forever. Once i changed it to a more reasonable 30 seconds, i start seeing the error message:
ORA-12537: Network Session: End of file
Is there an option in the Oracle ODP.NET, Managed Driver, or in the connection string, or in the OracleCommand
to tell the server to throw an error if there is an error in my SQL statement?
Bonus Chatter
Oracle provides two database drivers for ADO.net
- one is an ADO.net managed wrapper around the 100MB native database drivers that you must already have installed (Oracle.DataAccess)
- the other is a standalone 3.8 MB driver, written in pure managed code, that has no other dependencies (Oracle.ManagedDataAccess)
Microsoft had created an Oracle driver, which is included in the .NET Framework. But that driver is deprecated, and no longer functions in .NET 4.5 requires the full Oracle client software version 8.1.7 or greater to be installed (System.Data.OracleClient)