Alternatively, you can use the DBMS_PARALLEL_EXECUTE package to create the JOB .
Here are some hits:
Use create_chunks_by_sql with by_rowid => FALSE , i.e. using the identifier and create the exact number of blocks as necessary execution of the stored procedure.
In run_task set parallel_level to the desired degree of parallelism. This is the same number as above or below if you need to o throttle parallelism.
Pass the procedure call as the sql_stmt parameter, for example.
BEGIN test_proc(:start_id,:end_id); END;
Optionally, as you can see, you can pass the fragment number to the procedure, so you can use it as threadId .
Here is a complete example.
Create a task and 3 pieces
DECLARE l_stmt CLOB; BEGIN DBMS_PARALLEL_EXECUTE.create_task (task_name => 'parallel PL/SQL'); l_stmt := 'SELECT rownum, rownum FROM dual connect by level <= 3'; DBMS_PARALLEL_EXECUTE.create_chunks_by_sql(task_name => 'parallel PL/SQL', sql_stmt => l_stmt, by_rowid => FALSE); END; /
Run the task using DOP = 3
DECLARE l_sql_stmt VARCHAR2(32767); BEGIN l_sql_stmt := 'BEGIN test_proc(:start_id,:end_id); END;'; DBMS_PARALLEL_EXECUTE.run_task(task_name => 'parallel PL/SQL', sql_stmt => l_sql_stmt, language_flag => DBMS_SQL.NATIVE, parallel_level => 3); END; /
Delete task
BEGIN DBMS_PARALLEL_EXECUTE.drop_task('parallel PL/SQL'); END; /