title: ORA-04091 mutating table error when calling a function from a procedure
body: <p>I have a task:</p>
  
  <blockquote>
    <p>Write a procedure to update salary (salary * % of increment) in emp table based on grade. Use function to get increment</p>
  </blockquote>
  
  <p>This is my procedure:</p>
  
  <pre><code>CREATE OR REPLACE
    PROCEDURE sal_incre
    IS
      CURSOR c_cur
      IS
        SELECT * FROM emp_task;
    BEGIN
      UPDATE emp_task SET sal = sal + sal_incr(grade_id);
      FOR rec IN c_cur
      LOOP
        dbms_output.put_line(rec.empno||','||rec.ename||','||rec.sal);
      END LOOP;
    END;
  </code></pre>
  
  <p>This is my function code:</p>
  
  <pre><code>CREATE OR REPLACE
    FUNCTION sal_incr(
        p_grade NUMBER)
      RETURN
    IS
      v_inc NUMBER;
    BEGIN
      SELECT raise_percent
      INTO v_inc
      FROM sal_inc
      WHERE grade_id IN
        (SELECT grade_id FROM emp_task WHERE grade_id = p_grade
        );
      RETURN v_inc;
      COMMIT;
    END;
  </code></pre>
  
  <p>When I call the procedure I'm getting:</p>
  
  <pre><code>ORA-04091: table SCOTT.EMP_TASK is mutating, trigger/function may not see it
  ORA-06512: at "SCOTT.SAL_INCR", line 8
  ORA-06512: at "SCOTT.SAL_INCRE", line 6
  ORA-06512: at line 2
  </code></pre>
  
  <p>What am I doing wrong?</p>