If table have 0 rows exit procedure
<p>I have a procedure inside a package and I want to implement a logic, wich will not insert the temp table into the main table if the temp table have 0 rows, and then go to the next procedure of the package.</p>

<pre><code>IF (not exists(select 1 from temp)) THEN
   RETURN;
ELSE
   EXECUTE IMMEDIATE 'TRUNCATE TABLE main';
   INSERT --+APPEND 
          INTO main
          Select * from temp;
   EXECUTE IMMEDIATE 'TRUNCATE TABLE temp';
END IF;
</code></pre>

<p>With this solution, the package is compiled with error.</p>

<p>Can anyone give me some tips?</p>