title: OracleCommand Query Null parameters in where- ORA-01008: not all variables bound
body: <p>I have the following Method and both paramaters are null </p>
  
  <p>bool hasValue = HasValue(null,null);</p>
  
  <pre><code>    internal bool HasValue(int? param1, int? param2)
      {
          int count = 0;
          using (var conn = new OracleConnection(connectionString))
          {
                  using (var command = conn.CreateCommand())
                  {
                      command.CommandText = "select count(id) from  Table1 "
                      + "where ((Column1 = :PARAM1 and :PARAM1 Is Not Null) Or (Column1 Is Null and :PARAM1 Is Null)) "
                      + "AND ((Column2 = :PARAM2 and :PARAM2 Is Not Null) Or (Column2 Is Null and :PARAM2 Is Null))";
                      command.Parameters.Add("PARAM1", OracleDbType.Int16, 0, param1, ParameterDirection.Input);
                      command.Parameters.Add("PARAM2", OracleDbType.Int16, 0,param2, ParameterDirection.Input);
                      command.Connection.Open();
                      count = Convert.ToInt16(command.ExecuteScalar());
  
                      command.Connection.Close();
                  }
          }
  
          return count &gt; 0;
      }
  </code></pre>
  
  <p>The method fails with the following error "ORA-01008: not all variables bound"</p>
  
  <p>If I use just one parameter then its fine but when i add the second it fails with "ORA-01008: not all variables bound"</p>
  
  <p>Thanks in advance</p>