title: Add IF ELSE Condition in PL SQL stored procedure
body: <p>I have a scenario where I want to add an <code>IF ELSE</code> condition in my below procedure:</p>
  
  <p>I tried like below but it is not getting compiled</p>
  
  <pre><code>PROCEDURE VSAT_EXCEL_REPORT
  (
   P_R4GSTATE IN NVARCHAR2,
   TBLDATA OUT SYS_REFCURSOR
   )
    AS
    BEGIN
  
  OPEN TBLDATA FOR    
  
      IF P_R4GSTATE = "ALL"
  
      THEN           
  SELECT ENB.SAP_ID AS SAP_ID,CAND.CANDIDATEID AS CANDIDATE_ID,ENB.R4G_STATE AS STATE,ENB.SITE_TYPE AS SITE_TYPE,CAND.SITENAME AS SITE_NAME
   ,ENB.SITEID AS SITEID,ENB.PRIORITY_SITE AS PRIORITYSITE,ENB.CIRCLE AS CIRCLE,    
   DECODE (VTS.STATUS_NAME, null, 'Fill VSAT form', VTS.STATUS_NAME) AS STATUS,
          ENB.LATITUDE
         ,ENB.LONGITUDE
        ,VT.SITE_DETAILS_TECHNOLOGY
        ,VT.SITE_DETAILS_MOUNT_TYPE
        ,VT.SITE_DETAILS_ANTENNA_SIZE
        ,VT.SITE_DETAILS_AMSL        
        ,VT.SITE_DETAILS_PLATFORM_REQUIRED
        ,VT.SITE_DETAILS_PLATFORM_HEIGHT  
        ,VT.SITE_DETAILS_ROOFTOP_SITE     
        ,VT.SITE_DETAILS_NOOFLOORS        
        ,VT.SITE_DETAILS_ADD_ROOFTOP_SITE 
        ,VT.SITE_DETAILS_STRUCTURAL_STAB  
        ,VT.SITE_DETAILS_HEIGHT_OF_ANTENNA
        ,VT.SITE_DETAILS_SATELLITE_BAND   
        ,VT.ANTENNA_DISTANCE_NEAR_AIRPORT 
        ,VT.ANTENNA_AIRPORT_NAME          
        ,VT.GSAT_LOS_16_55E               
        ,VT.GSAT_LOS_18_74E               
        ,VT.GSAT_LOS_12_83E 
   FROM R4G_OSP.ENODEB ENB
  INNER JOIN R4G_OSP.CANDIDATE CAND ON ENB.SAP_ID = CAND.SAP_ID 
  LEFT JOIN TBL_VSAT_MST_DETAIL VT ON ENB.SAP_ID = VT.SAP_ID
  LEFT JOIN TBL_VSAT_STATUS_MST VTS ON VT.STATUS_ID = VTS.STATUS_ID
  WHERE ENB.SCOPE = 'EnodeB-Connected_MW'
  AND ENB.SITEBACKHAUL = 'MW'
  AND CAND.STATUS = 'Fill Vendor Survey Form' 
  AND UPPER(STATE) IN 
  (SELECT REGEXP_SUBSTR(UPPER(P_R4GSTATE),'[^,]+', 1, LEVEL) AS RFIELDS FROM DUAL
                                            CONNECT BY REGEXP_SUBSTR(UPPER(P_R4GSTATE), '[^,]+', 1, LEVEL) IS NOT NULL);
  
                                            ELSE
                                            --Some condtion
    END VSAT_EXCEL_REPORT; 
  </code></pre>