BEGIN

  dbms_resource_manager.create_pending_area;
  dbms_resource_manager.create_plan(plan    => 'EMAIL_BATCH_PLAN'
                                   ,COMMENT => 'Resource plan for use as a SMIME email queue');

  dbms_resource_manager.create_consumer_group(consumer_group => 'EMAIL_BATCH_GROUP'
                                             ,COMMENT        => 'Resource group for email queue');

  dbms_resource_manager.create_plan_directive(plan             => 'EMAIL_BATCH_PLAN'
                                             ,group_or_subplan => 'OTHER_GROUPS'
                                             ,COMMENT          => 'No Comment');

  dbms_resource_manager.create_plan_directive(plan                => 'EMAIL_BATCH_PLAN'
                                             ,group_or_subplan    => 'EMAIL_BATCH_GROUP'
                                             ,COMMENT             => 'Limit active sessions to a single session'
                                             ,active_sess_pool_p1 => 1);

  dbms_resource_manager.submit_pending_area;

  dbms_scheduler.create_job_class(job_class_name          => 'BATCH_EMAIL_CLASS'
                                 ,resource_consumer_group => 'EMAIL_BATCH_GROUP');
                                 

END;

PROMPT GRANT CREATE EXTERNAL JOB to eft_nom;
PROMPT grant create job to eft_nom
PROMPT grant execute on dbms_lock to eft_nom
PROMPT Drop library
