I am currently evaluating Oracle ODP.NET DataProvider and I am having a problem in one of our test arrays: When the same command text is executed with different types of parameters, the parameter type of the first command executed in all of the following commands is used.
Take for example the following code:
const int sampleInt32 = 1234567890; const string sampleNvarchar = "someTestString"; const string sqlCommandtext = "SELECT :PARAM PARAM FROM DUAL"; using (OracleConnection connection = new OracleConnection(builder.ConnectionString)) { connection.Open();
If commandInt32 is executed before the NVarchar command, the execution of the NVarchar command fails with ORA-01722 - Invalid number. If the order is switched so that the NVarchar command is executed first, it fails with "The specified cast is invalid" on reader.GetDecimal.
So far, I have been trying to set StatementCacheSize = 0; Accumulation = false; StatementCachePurge = true as parameters of ConnectionString, but I cannot get this to work.
Is there anything that I will skip, or are there any other options worth trying?
EDIT . Maybe some experience is why it is necessary / required: we do not use ODP or any other Dataprovider directly in our application (or at least: we are on our way to achieve this goal), there is a DataLayer between them, which performs database / provider optimization and connection health monitoring, ...
In this layer, you can call StoredProcedures, having the ability to configure parameter settings. Some of our procedures have Clobs as parameter types, because sometimes the value may be longer than the characters x, but most likely it will be shorter. Therefore, before executing through ExecuteNonQuery with an ArrayBindCount set to y, the parameter values ββare checked if Clob can be passed as varchar (Nclob as Nvarchar). Interlacing reduces the time it takes to execute 2500 records from 500 ms to 200 ms due to the loss of several lines of test length. And this re-binding can only be done if the type of the parameter can be changed. Without this option, we will need to execute it as Clob every time, taking a performance hit.