title: Oracle with CASE Statement in WHERE clause
body: <p>Below is my attempt to include a <code>CASE STATEMENT</code> in a <code>WHERE</code> clause, it's not working. Anyone knows how I can correct this?</p>
  
  <pre><code>PROCEDURE GetBatchTotals(pEntityName VARCHAR DEFAULT NULL) IS
  
  BEGIN
  
    -- Sample Query
    SELECT
      e.ColumnName
    FROM
      Schema.TableName e
    WHERE
    (
      CASE
        WHEN pEntityName IS NULL THEN
          e.ColumnName != '' -- Just to select everything in the table
        ELSE
          e.ColumnName = pEntityName
      END
    );
  
  END GetBatchTotals;
  </code></pre>
  
  <p>I cannot seem to make sense of the examples I've seen already posted. Here's another attempt without using a CASE STATEMENT but returns no result:</p>
  
  <pre><code>SELECT
    e.ColumnName
  FROM
    Schema.TableName e
  WHERE
    (pEntityName IS NULL AND e.ColumnName != '') OR
    (pEntityName IS NOT NULL AND e.ColumnName = pEntityName);
  </code></pre>
  
  <p>Anyway, here's the true sample query that returns no result:
  <a href="https://i.stack.imgur.com/KGM7f.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/KGM7f.png" alt="enter image description here"></a></p>
  
  <p>And then here's the table with data:
  <a href="https://i.stack.imgur.com/ndnTf.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ndnTf.png" alt="enter image description here"></a>
  Thanks in advance.</p>