title: Oracle SQL : How add IF condition inside FORALL LOOP
body: <p>I am trying to merge table into <code>emp1</code>, if the select_count is not equal to 0. But I couldn't add select and if statement inside FORALL Loop. Can anyone help me to achieve this? Thanks.</p>
  
  <pre><code>FORALL i IN 1 .. v_emp.LAST
      select count(emp_id) into select_count from emp where emp_id=v_emp(i).emp_id;
      IF select_count &lt;&gt; 0 THEN 
         MERGE INTO emp1 e1 using dual ON(a.id=b.id)
         WHEN MATCHED
           //Update statement
         WHEN NOT MATCHED 
           //Insert statement
      END IF;
  </code></pre>
  
  <p>The above code throwing error message:</p>
  
  <blockquote>
    <p>PLS-00201 : Identifier 'I' must be declared. </p>
  </blockquote>