title: How to execute an Oracle PLSQL block in Java
body: <p>I have an PL/SQL block like this:</p>
  
  <pre><code>BEGIN
    FOR i IN 1..100
    LOOP
      UPDATE rptbody 
         SET comments = 'abcs';
       WHERE (rptno&gt; 100 and rptno &lt; 200) and ROWNUM&lt;2;
      COMMIT;
    END LOOP;
  END;
  </code></pre>
  
  <p>This block needs to be executed using Oracle JDBC. I have tried the following methods:</p>
  
  <ul>
  <li><p>Tried to execute this using Statement object. Since this is a block, an exception was raised saying that this is not an sql statement</p></li>
  <li><p>This can be split up into sql statements, but I have 100s of such blocks which would be cumbersome for the code and thought of leaving this to the sqlplus.</p></li>
  <li><p>Tried with CallableStatement which did not work as well.</p></li>
  </ul>
  
  <p>Any solutions would be helpful.</p>