ORA-29494: invalid state for run task error with DBMS_PARALLEL_EXECUTE
<p>I am running a PL/SQL procedure with DBMS_PARALLEL_EXECUTE. I get stuck with ORA-29494: invalid state for run task error. My code is as below:</p>

<p>Below is the sample output for the DBMS_OUTPUT statement:</p>

<p>PROCESSING
5743
PROCESSING
5744</p>

<p>When I individually run the create task, chunk task and run task with input rowid from the user_parallel_execute_chunks, It works just fine for individual chunks. Also without loop, the task runs for all the chunks and ends with an error saying chunk_not_found. To handle that I used the loop, But I am not able to make it work</p>

<pre><code>CREATE OR REPLACE PROCEDURE code_parse_wrapper AS
l_sql_stmt VARCHAR2(32767);
l_chunk_id NUMBER;
l_start_rowid ROWID;
l_end_rowid ROWID;
l_any_rows BOOLEAN;
l_try NUMBER;
l_status NUMBER;
l_stmt CLOB;
V_CHUNK_ID NUMBER;
V_STATUS VARCHAR2(30);
BEGIN
BEGIN

dbms_parallel_execute.drop_task(task_name =&gt; 'parallel_processing');
DBMS_OUTPUT.PUT_LINE('TASK DROPPED');
END;    
BEGIN
dbms_parallel_execute.create_task(task_name =&gt; 'parallel_processing');
DBMS_OUTPUT.PUT_LINE('TASK CREATED');
END;


-- Create Chunks

BEGIN
dbms_parallel_execute.create_chunks_by_rowid
(
    'parallel_processing',
    'SchemaName',
    'ORDER_DETAIL',
    FALSE,
    50000
); 
END;

BEGIN   
LOOP
    dbms_parallel_execute.get_rowid_chunk
    (
        task_name =&gt; 'parallel_processing',
        chunk_id =&gt; l_chunk_id,
        start_rowid =&gt; l_start_rowid,
        end_rowid =&gt; l_end_rowid,
        any_rows =&gt; l_any_rows
    );
  select STATUS INTO V_STATUS from user_parallel_execute_tasks where task_name =  'parallel_processing';
    DBMS_OUTPUT.PUT_LINE(V_STATUS);

    l_sql_stmt := ' begin CODE_PARSE6_AK( :start_id, :end_id ); end;';
    DBMS_OUTPUT.PUT_LINE(l_chunk_id);
--    DBMS_OUTPUT.PUT_LINE(l_sql_stmt);
 IF (l_any_rows = false) THEN 
 EXIT;
  END IF;   

BEGIN
    -- Get next unassigned chunk.
    --  EXECUTE IMMEDIATE 'l_sql_stmt USING l_start_rowid, l_end_rowid'; 

        dbms_parallel_execute.run_task('parallel_processing',
                                                     l_sql_stmt,
                                                     DBMS_SQL.NATIVE,
                                                    parallel_level =&gt; 10
                                                  );

                                                  l_try := 0;
 l_status := dbms_parallel_execute.task_status('parallel_processing');

 WHILE(l_try &lt; 2 and l_status != dbms_parallel_execute.finished)     LOOP
             l_try := l_try + 1;
             dbms_parallel_execute.resume_task('parallel_processing');
             l_status :=    dbms_parallel_execute.task_status('parallel_processing'); 


    dbms_parallel_execute.set_chunk_status
        (
            task_name =&gt; 'parallel_processing',
            chunk_id =&gt; l_chunk_id,
            status =&gt; dbms_parallel_execute.processed
        ); 

        END LOOP;

    EXCEPTION

        WHEN OTHERS THEN
            -- Record chunk error.
            dbms_parallel_execute.set_chunk_status
            (
                task_name =&gt; 'parallel_processing',
                chunk_id =&gt; l_chunk_id,
                status =&gt; dbms_parallel_execute.processed_with_error,
                err_num =&gt; SQLCODE,
                err_msg =&gt; SQLERRM
            );
            END;

 COMMIT;

END LOOP;
END;


END;
</code></pre>