title: Nesting a Case statement within an IF statement
body: <p>I'm getting a compiler error on the last CASE statement located in where clause. I can't seem to figure out what I am doing wrong...any help would be appreciated thank you.</p>
  
  <pre><code>P1: BEGIN
  DECLARE cursor1 CURSOR WITH RETURN FOR
      SELECT DISTINCT MPWBIPS.MIP_NO,                                  
          MPWBIPS.ITEM_NO,                                 
          MPWBIPS.MATL_PLNR_ID,                            
          MPWBIPS.ITEM_OBS_STATUS,                       
          MPWBMIT.EXCS_ITEM_COST_TOT,
          MPWBMIP.TRGT_CHGOVR_DATE,
          SLOTLOC.LOT_FROM_EFF_DATE,              
      FROM MPWBIPS MPWBIPS                                          
      INNER JOIN MPWBMIT MPWBMIT 
          ON MPWBMIT.MIP_NO = MPWBIPS.MIP_NO             
          AND MPWBMIT.ITEM_NO = MPWBIPS.ITEM_NO 
      INNER JOIN MPPLNR MPPLNR
          ON MPWBIPS.MATL_PLNR_ID = MPPLNR.MATL_PLNR_ID
      INNER JOIN MPWBMIP MPWBMIP
          ON MPWBIPS.MIP_NO = MPWBMIP.MIP_NO
      INNER JOIN SMPROJ_DPIMS SMPROJ
          ON MPWBIPS.MIP_NO = SMPROJ.MIP_NO
      INNER JOIN SLOTLOC_DPIMS SLOTLOC
          ON SMPROJ.MFG_CHGOVR_PER = SLOTLOC.LOT
  
      WHERE plannerID =
          CASE WHEN mgrIndc = 'Y' THEN
              MPPLNR.MGR_LID
          WHEN suprvIndc = 'Y' THEN
              MPPLNR.SPRVSR_LID
          WHEN plannerID = '' THEN
              ''
          ELSE
              MPPLNR.MATL_PLNR_ID
          END
  
          AND CASE WHEN obsStatus = 'ACTION' THEN
                      MPWBIPS.ITEM_OBS_STATUS &lt;&gt; 'RESOLVED 99'
                      AND MPWBIPS.ITEM_OBS_STATUS &lt;&gt; 'EXCESS 90'
                  WHEN obsStatus = 'ALL' OR obsStatus = '' THEN
                      obsStatus = ''
                  ELSE
                      MPWBIPS.ITEM_OBS_STATUS = obsStatus
                  END
          AND (COALESCE(mipNo, '') = '' OR MPWBIPS.MIP_NO = mipNo);
  OPEN cursor1;
  </code></pre>
  
  <p>END P1</p>