Oracle Consulting Oracle Training Development

Remote DBA

Remote DBA Plans  

Remote DBA Service

Remote DBA RAC

   
Remote DBA Oracle Home
Remote DBA Oracle Training
Remote DBA SQL Tuning Consulting
Remote DBA Oracle Tuning Consulting
Remote DBA Data Warehouse Consulting
Remote DBA Oracle Project Management
Remote DBA Oracle Security Assessment
Remote DBA Unix Consulting
Burleson Books
Burleson Articles
Burleson Web Courses
Burleson Qualifications
Oracle Links
Remote DBA Oracle Monitoring
Remote DBA Support Benefits
Remote DBA Plans & Prices
Our Automation Strategy
What We Monitor
Oracle Apps Support
Print Our Brochure
Contact Us (e-mail)
Oracle Job Opportunities
Oracle Consulting Prices





   

 

 

 

Remote DBA services

Remote DBA Support

Remote DBA RAC

Remote DBA Reasons

Remote Oracle Tuning

Remote DBA Links

Oracle DBA Support

Oracle DBA Forum

Oracle Disaster

Oracle Training

Oracle Tuning

Oracle Training

 Remote DBA SQL Server

Remote MSSQL Consulting

Oracle DBA Hosting

Oracle License Negotiation

 

 


 

 

 

        
 

 Oracle Create Job Class
Oracle Tips by Burleson Consulting

Advanced Oracle Utilities: The Definitive Reference by Rampant TechPress is written by four of the top Oracle database experts (Bert Scalzo, Donald Burleson, and Steve Callan).  The following is an excerpt from the book.

Job Classes

Job classes allow the grouping of jobs with similar characteristics and resource requirements to ease administration.  If the job_class parameter of the create_job procedure is undefined, the job is assigned to a job class called DEFAULT_JOB_CLASS.

 

Job classes are created using the create_job_class procedure listed below.

 

PROCEDURE create_job_class(

  job_class_name          IN VARCHAR2,

  resource_consumer_group IN VARCHAR2     DEFAULT NULL,

  service                 IN VARCHAR2     DEFAULT NULL,

  logging_level           IN PLS_INTEGER  DEFAULT DBMS_SCHEDULER.LOGGING_RUNS,

  log_history             IN PLS_INTEGER  DEFAULT NULL,

  comments                IN VARCHAR2     DEFAULT NULL)

 

The parameters associated with this procedure and their usage are as follows:

  • job_class_name - A name that uniquely identifies the job class

  • resource_consumer_group - The resource consumer group associated with the job class

  • service - The service database object the job belongs to, not the tnsnames.ora service

  • logging_level  - The amount of logging that should be done for this job specified by the constants logging_off, logging_runs, and logging_full

  • log_history - The number of days the logging information is kept before purging

  • comments - Free text allowing the user to record additional information

Suffice it to say that it must be decided with which resource consumer group the job class should be associated.  Information about resource consumer groups can be displayed using the  view.

 

select

   consumer_group

from

   dba_rsrc_consumer_groups

;

 

CONSUMER_GROUP

------------------------------

OTHER_GROUPS

DEFAULT_CONSUMER_GROUP

SYS_GROUP

LOW_GROUP

AUTO_TASK_CONSUMER_GROUP

 

With this information, a new job class can be defined as follows:

 

BEGIN

  DBMS_SCHEDULER.create_job_class (

    job_class_name          => 'test_job_class',

    resource_consumer_group => 'default_consumer_group');

END;

/

 

Figure 11.21 shows the Create Job Class screen in the OEM DB Control.

 

Figure 11.21 – OEM DB Control: Create Job Class

 

Information about job classes can be displayed using the dba_scheduler_job_classes view.  The following script uses this view:

 

job_classes.sql

 

select

   job_class_name,

   resource_consumer_group

from

   dba_scheduler_job_classes

;

 

Here is the output from the job_classes.sql script:

 

SQL> @job_classes

 

JOB_CLASS_NAME                 RESOURCE_CONSUMER_GROUP

------------------------------ ------------------------------

DEFAULT_JOB_CLASS

AUTO_TASKS_JOB_CLASS           AUTO_TASK_CONSUMER_GROUP

TEST_JOB_CLASS                 DEFAULT_CONSUMER_GROUP

 

3 rows selected.

 

Figure 11.22 shows the Scheduler Job Classes screen in the OEM DB Control.

 

Figure 11.22 – OEM DB Control: Scheduler Job Classes

 

Jobs can be assigned to a job class during creation.  It is also possible to assign a job to an alternative job class after creation using one of the set_attribute procedure overloads.

 

BEGIN

  -- Job defined and assigned to a job class.

  DBMS_SCHEDULER.create_job (

    job_name      => 'test_prog_sched_class_job_def',

    program_name  => 'test_plsql_block_prog',

    schedule_name => 'test_hourly_schedule',

    job_class     => 'test_job_class',

    enabled       => TRUE,

    comments      => 'Job defined and assigned to a job class ');

END;

/

BEGIN

  -- Assign an existing job to a job class.

  DBMS_SCHEDULER.set_attribute (

    name      => 'test_prog_sched_job_definition',

    attribute => 'job_class',

    value     => 'test_job_class');

END;

/

 

The output from the jobs_10g.sql script shows that the job classes associated with these jobs have been set correctly.

 

SQL> @jobs_10g job_user

 

OWNER      JOB_NAME                       JOB_CLASS        ENABLE

---------- ------------------------------ ---------------- ------

NEXT_RUN_DATE

-----------------------------------------------------------------

REPEAT_INTERVAL

-----------------------------------------------------------------

JOB_USER   TEST_FULL_JOB_DEFINITION       DEFAULT_JOB_CLASS  TRUE

22-JUN-04 15.00.08.900000 +01:00

freq=hourly; byminute=0

 

JOB_USER   TEST_PROG_SCHED_JOB_DEFINITION TEST_JOB_CLASS     TRUE

22-JUN-04 15.00.16.200000 +01:00

 

JOB_USER   TEST_PROG_JOB_DEFINITION       DEFAULT_JOB_CLASS  TRUE

22-JUN-04 15.00.09.600000 +01:00

freq=hourly; byminute=0

 

JOB_USER   TEST_SCHED_JOB_DEFINITION      DEFAULT_JOB_CLASS  TRUE

22-JUN-04 15.00.16.200000 +01:00

 

JOB_USER   ARGUMENT_JOB_DEFINITION        DEFAULT_JOB_CLASS  TRUE

22-JUN-04 15.00.16.200000 +01:00

 

JOB_USER   TEST_PROG_SCHED_CLASS_JOB_DEF  TEST_JOB_CLASS     TRUE

22-JUN-04 15.00.16.200000 +01:00

 

6 rows selected.

 

Job classes can be removed using the drop_job_class procedure listed below:

 

PROCEDURE drop_job_class (

  job_class_name          IN VARCHAR2,

  force                   IN BOOLEAN DEFAULT FALSE)

 

The parameters associated with this procedure and their usage are as follows:

  • job_class_name - A name that specifies a single or comma separated list of job class names

  • force - When set to TRUE, all jobs that are assigned to the job class are disabled and have their job class set to the default.  When set to FALSE, attempting to drop a job class that has dependent jobs will cause an error.

The following code example shows how a job class can be removed.

 

BEGIN

  DBMS_SCHEDULER.drop_job_class (

    job_class_name => 'test_job_class',

    force          => TRUE);

END;

/

 

The output of the job_classes.sql script shows that the job class has been removed successfully.

 

SQL> @job_classes

 

JOB_CLASS_NAME                 RESOURCE_CONSUMER_GROUP

------------------------------ ------------------------------

DEFAULT_JOB_CLASS

AUTO_TASKS_JOB_CLASS           AUTO_TASK_CONSUMER_GROUP

 

2 rows selected.

 

Now that the creation of job classes has been presented, the next section will cover windows, which is another type of scheduler administration object.

     

Remote DBA Service
 

Oracle Tuning Book

 

Advance SQL Tuning Book 

BC Oracle support

Oracle books by Rampant

Oracle monitoring software

 

 

 

 

 

 

 

 

 

BC Remote Oracle Support

Remote DBA

Remote DBA Services

Copyright © 1996 -  2013 by Burleson. All rights reserved.

Oracle® is the registered trademark of Oracle Corporation.