title: Oracle PL SQL CASE in WHERE clause
body: <p>I know i could probably accomplish this by easily putting two whole statements in a CASE statement itself, but i'm new to SQL and trying to learn to write this the most efficient and intelligent way without duplicating any logic, and so i figure maybe there is a way i can turn a where condition line on or off basically.</p>
  
  <p>I have the following statement(which doesn't work btw, missing a keyword it says):</p>
  
  <pre><code>      OPEN O_CURSOR FOR
         SELECT S.STORE_NO_4_DIGIT AS STORE_NO, S.STORE_NAME
           FROM RFS.RF_STORE S
          WHERE S.TYPE_CODE != 'W'
          AND
              CASE I_CAN_BE_CLOSED
                  WHEN 0 THEN
                  S.CLOSE_DATE IS NULL
              END                
       ORDER BY S.STORE_NO_4_DIGIT;
  </code></pre>
  
  <p>There is two cases based on the input variable I_CAN_BE_CLOSED, values 0 or 1.</p>
  
  <p>In one case i want to allow it to return stores with only NULL CLOSE_DATES, and in the other case i want it to return either(both closing and non-closing stores). </p>