Create a resource, and limit jobs to 1
begin dbms_scheduler.create_resource(resource_name=>'SO_TEST_RESOURCE',units=>'1'); END;
While I can create a job, assign a resource, and even a priority, the subsequent jobs (assigned to the same resource and various priorities) that are queued, are run in random order not FIFO, and not in priority order. Looking for a way to force the next job queued (assigned to that same resource) to be the one that runs next.
DBMS_SCHEDULER.create_job (
job_name => 'SO_JOB1_TEST_RESOURCE',
job_type => 'PLSQL_BLOCK',
job_action => 'begin DBMS_SESSION.sleep(40); end;',
auto_drop => true,
start_date => systimestamp,
enabled => false);
DBMS_SCHEDULER.set_resource_constraint (
object_name => 'SO_JOB1_TEST_RESOURCE',
resource_name => 'SO_TEST_RESOURCE',
units => 1);
DBMS_SCHEDULER.SET_ATTRIBUTE(
NAME => 'SO_JOB1_TEST_RESOURCE',
ATTRIBUTE => 'job_priority',
VALUE =>1 );
DBMS_SCHEDULER.enable('SO_JOB1_TEST_RESOURCE');
.... adding more jobs 2, 3, 4 run in random order