title: How to count how many sql statements are there in an SQL file?
body: <p>So, given an SQL file to be executed in Oracle, we are asked to determine how many blocks are to be executed within the SQL file. For example, there is one block in an SQL file containing the following command,</p>
  
  <pre><code>CREATE TABLE customer (id varchar2(42));
  </code></pre>
  
  <p>two blocks in the following SQL file,</p>
  
  <pre><code>ALTER TABLE customer ADD name varchar2(42);
  ALTER TABLE customer DROP COLUMN id;
  </code></pre>
  
  <p>and three blocks in the following SQL file </p>
  
  <pre><code>CREATE OR REPLACE PROCEDURE printHelloWorld IS
  BEGIN
      dbms_output.put_line('Hello World!');
  END;
  /
  
  INSERT INTO customer VALUES ('ivan');
  
  DROP TABLE customer;
  </code></pre>
  
  <p>We can't assume anything else about the input, other than the fact it will be executed without any error in Oracle SQLDeveloper. </p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>The purpose of asking the question is to ensure that there would only be one statement, which is to be executed, in the SQL file. I am also open to the answer of this question. It would be even better to be able to create a script to split a multiple-statement SQL file to multiple files.</p>