title: Execute a procedure inside a function (ORA-14551 error)
body: <p>This question is related to my <a href="https://stackoverflow.com/questions/14768880/calling-procedure-from-oracle-to-crystal-report">previous question</a>.<br/><br/></p>
  
  <p>I have a procedure(<code>PROC_YEARLYACTIVELIST2</code>) that will show all records that is active on a specified year.<br/>
  It will delete the previous contents of <code>TBLACTIVELISTYEARLY2</code> and insert the result from <code>PROC_YEARLYACTIVELIST2</code>.<br/>
  <br/>
  I created a function that will execute <code>TBLACTIVELISTYEARLY2</code>, Select all records from <code>TBLACTIVELISTYEARLY</code> and put it into <code>CURSOR C_IH</code>, and return the table for Crystal Report.<br/>
  <br/>
  Below is just a part of the code:<br/></p>
  
  <pre>
  
  DECLARE
    CURSOR C_IH IS SELECT * FROM tblActiveListYearly2;
  
    ctr INT;
    i NUMBER;  
    currDeploymentComputer COL_TYPE_DEPLOYMENT_COMPUTER := COL_TYPE_DEPLOYMENT_COMPUTER NULL);
    R_IH C_IH%ROWTYPE;
  
   BEGIN
   PROC_YEARLYACTIVELIST2(in_year);
  
    OPEN C_IH;
     i := 0;
      LOOP (....)
  </pre>
  
  <p>I've tried to call the function as<br/></p>
  
  <pre><code>SELECT GETDEPLOYMENT_COMPUTER('2012') from dual;
  </code></pre>
  
  <p>And has an <code>ORA-14551</code> error</p>
  
  <pre><code>ORA-14551: cannot perform a DML operation inside a query 
  ORA-06512: at "NPLS.PROC_YEARLYACTIVELIST2", line 12
  ORA-06512: at "NPLS.GETDEPLOYMENT_COMPUTER", line 3
  </code></pre>
  
  <p>Searched for it and found that it is because of the conflict with <code>INSERT</code>, <code>UPDATE</code> or <code>DELETE</code> and <code>DUAL</code>.</p>
  
  <p>Is there any other way to execute my procedure in a function that will return a table?</p>
  
  <p>THANKS!</p>