Documente Academic
Documente Profesional
Documente Cultură
Tools Used:
Oracle Database Express Edition 11g Release 2
SQL Developer 4.2
In first part of the article we will briefly visit the components used to
schedule job and what are the prerequisites that needs to be done before
any of the component is created.
Job
A job is the combination of a schedule and a program, along with any
additional arguments required by the program. A schedule is nothing but the
frequency of job execution. A job can perform a task that is defined by one of
these –
PL/SQL block
Stored Procedure
Remote Stored Procedure
Chain
Program
Executable
Program
A program is a collection of metadata about a particular task. The programs
are not schedulable on their own. You need to define program using one of –
PL/SQL block
Stored Procedure
Remote Stored Procedure
Executable
Chain
A chain is a series of programs that are linked together to perform a
particular group of activities. To create a chain, you need to follow below
steps –
Create a chain
Define the steps in the chain
Add rules
Enable (If you are using SQL Developer, you can skip this step as you
have option to enable chain at creation time.)
Create a job that runs this chain as scheduled.
Prerequisites
To create a job, program and chains we need to grant our user some
privileges. To do that connect to database using sql plus command line and
execute below code blocks. You need to connect as SYSDBA
Prerequisites Grants
Oracle PL/SQL
1 BEGIN
2 GRANT CREATE ANY JOB TO <USER NAME>;
3 GRANT EXECUTE ON DBMS_SCHEDULER TO <USER NAME>;
4 GRANT MANAGE SCHEDULER TO <USER NAME>;
5 END;
6
7 BEGIN
8 DBMS_RULE_ADM.GRANT_SYSTEM_PRIVILEGE(DBMS_RULE_ADM.CREATE_RULE_OBJ, '<USER
9 NAME>');
1 DBMS_RULE_ADM.GRANT_SYSTEM_PRIVILEGE(DBMS_RULE_ADM.CREATE_RULE_SET_OBJ, '<USER
0 NAME>');
1 DBMS_RULE_ADM.GRANT_SYSTEM_PRIVILEGE(DBMS_RULE_ADM.CREATE_EVALUATION_CONTEXT_O
1 BJ, '<USER NAME>');
1 END;
2 /
Illustration
For illustrations purpose we have defined 2 tables and 3 procedures. Brief
description about them is as
1. In the sql developer right click on Job and select New Job (Wizard)
2. You will see below screen. Specify name and description.
3. Keep Job class as default.