we have a table in an Oracle Database which contains a column with the type Char(3 Byte).
Now we use a parameterized sql to select some rows with a DBNull.Value and it doesn t work:
OracleCommand command = null;
OracleDataReader dataReader = null;
string sql = "select * from TEST_TABLE where COLUMN_1 = :COLUMN_1";
try
{
OracleConnection connection = (OracleConnection) dbConnection;
command = new OracleCommand( sql, connection );
OracleParameter param_1 = new OracleParameter( "COLUMN_1", OracleDbType.Char );
command.Parameters.Add( param_1 );
param_1.Value = DbNull.Value;
dataReader = command.ExecuteReader( );
int recordCount = 0;
while( dataReader.Read( ) == true )
{
recordCount++;
}
Console.WriteLine( "Count = " + recordCount ); // is 0
}
[...]
Did i miss something? We definitly have some rows which contains a DBNull,
but the circumstance that you would write a normal sql with "is null" and not "= null"
is also noticeable.
Can somebody explain this behaviour? How do you write a parameterized sql where you need a condition to check for a DBNull?
Thanks