1 PACKAGE dbms_job AUTHID CURRENT_USER IS
2
3 -- for backward compatibility. Not used anymore.
4 any_instance CONSTANT BINARY_INTEGER := 0;
5
6 -- Parameters are:
7 --
8 -- JOB is the number of the job being executed.
9 -- WHAT is the PL/SQL procedure to execute.
10 -- The job must always be a single call to a procedure. The
11 -- routine may take any number of hardcoded parameters.
12 -- Special parameter values recognized are:
13 -- job: an in parameter, the number of the current job
14 -- next_date: in/out, the date of the next refresh
15 -- broken: in/out, is the job broken. The IN values is FALSE.
16 -- Always remember the trailing semicolon.
17 -- Some legal values of WHAT (assuming the routines exist) are
18 -- 'myproc( ''10-JAN-82'', next_date, broken);'
19 -- 'scott.emppackage.give_raise( ''JENKINS'', 30000.00);'
20 -- 'dbms_job.remove( job);'
21 -- NEXT_DATE is the date at which the job will next be automatically run,
22 -- assuming there are background processes attempting to run it.
23 -- INTERVAL is a date function, evaluated immediately before the job starts
24 -- executing. If the job completes successfully, this new date is placed
25 -- in NEXT_DATE. INTERVAL is evaluated by plugging it into the statement
26 -- select INTERVAL into next_date from dual;
27 -- INTERVAL must evaluate to a time in the future. Legal intervals include
28 -- 'sysdate + 7' -- execute once a week
29 -- 'NEXT_DAY(sysdate,''TUESDAY'')' -- execute once every tuesday
30 -- 'null' -- only execute once
31 -- If INTERVAL evaluates to null and a job completes successfully, then
32 -- the job is automatically deleted from the queue.
33
34 PROCEDURE isubmit ( job IN BINARY_INTEGER,
35 what IN VARCHAR2,
36 next_date IN DATE,
37 interval IN VARCHAR2 DEFAULT 'null',
38 no_parse IN BOOLEAN DEFAULT FALSE);
39 -- Submit a new job with a given job number.
40
41 PROCEDURE submit ( job OUT BINARY_INTEGER,
42 what IN VARCHAR2,
43 next_date IN DATE DEFAULT sysdate,
44 interval IN VARCHAR2 DEFAULT 'null',
45 no_parse IN BOOLEAN DEFAULT FALSE,
46
47 -- Bug 1346620: replace pkg vars with constants.
48 -- Default for instance = dbms_job.any_instance.
49 instance IN BINARY_INTEGER DEFAULT 0,
50 force IN BOOLEAN DEFAULT FALSE );
51 -- Submit a new job. Chooses JOB from the sequence sys.jobseq.
52 -- instance and force are added for jobq queue affinity
53 -- If FORCE is TRUE, then any positive integer is acceptable as the job
54 -- instance. If FORCE is FALSE, then the specified instance must be running;
55 -- otherwise the routine raises an exception.
56 -- For example,
57 -- variable x number;
58 -- execute dbms_job.submit(:x,'pack.proc(''arg1'');',sysdate,'sysdate+1');
59
60 PROCEDURE remove ( job IN BINARY_INTEGER );
61 -- Remove an existing job from the job queue.
62 -- This currently does not stop a running job.
63 -- execute dbms_job.remove(14144);
64
65 PROCEDURE change ( job IN BINARY_INTEGER,
66 what IN VARCHAR2,
67 next_date IN DATE,
68 interval IN VARCHAR2,
69 instance IN BINARY_INTEGER DEFAULT NULL,
70 force IN BOOLEAN DEFAULT FALSE);
71 -- Change any of the the user-settable fields in a job
72 -- Parameter instance and force are added for job queue affinity
73 -- If what, next_date,or interval is null, leave that value as-is.
74 -- instance defaults to NULL indicates instance affinity is not changed.
75 -- If FORCE is FALSE, the specified instance (to which the instance number
76 -- change) must be running. Otherwise the routine raises an exception.
77 -- If FORCE is TRUE, any positive integer is acceptable as the job instance.
78 -- execute dbms_job.change( 14144, null, null, 'sysdate+3');
79
80 PROCEDURE what ( job IN BINARY_INTEGER,
81 what IN VARCHAR2 );
82 -- Change what an existing job does, and replace its environment
83
84 PROCEDURE next_date ( job IN BINARY_INTEGER,
85 next_date IN DATE );
86 -- Change when an existing job will next execute
87
88 PROCEDURE instance ( job IN BINARY_INTEGER,
89 instance IN BINARY_INTEGER,
90 force IN BOOLEAN DEFAULT FALSE);
91 -- Change job instance affinity. FORCE parameter works same as in SUBMIT
92
93 PROCEDURE interval ( job IN BINARY_INTEGER,
94 interval IN VARCHAR2 );
95 -- Change how often a job executes
96
97 PROCEDURE broken ( job IN BINARY_INTEGER,
98 broken IN BOOLEAN,
99 next_date IN DATE DEFAULT SYSDATE );
100 -- Set the broken flag. Broken jobs are never run.
101
102 PROCEDURE run ( job IN BINARY_INTEGER,
103 force IN BOOLEAN DEFAULT FALSE);
104 -- Run job JOB now. Run it even if it is broken.
105 -- Running the job will recompute next_date, see view user_jobs.
106 -- execute dbms_job.run(14144);
107 -- Warning: this will reinitialize the current session's packages
108 -- FORCE is added for job queue affinity
109 -- If FORCE is TRUE, instance affinity is irrelevant for running jobs in
110 -- the foreground process. If FORCE is FALSE, the job can be run in the
111 -- foreground only in the specified instance. dbms_job.run will raise an
112 -- exception if FORCE is FALSE and the connected instance is the wrong one.
113
114 PROCEDURE user_export ( job IN BINARY_INTEGER,
115 mycall IN OUT VARCHAR2);
116 -- Produce the text of a call to recreate the given job
117
118 PROCEDURE user_export ( job IN BINARY_INTEGER,
119 mycall IN OUT VARCHAR2,
120 myinst IN OUT VARCHAR2);
121 -- Procedure is added for altering instance affinity (8.1+) and perserve the
122 -- compatibility
123
124 --------------------------------------------------------------
125 -- Return boolean value indicating whether execution is in background
126 -- process or foreground process
127 -- jobq processes are no longer background processes, background_processes
128 -- will be removed in 8.3 or later
129 -------------------------------------------------------------
130 FUNCTION background_process RETURN BOOLEAN;
131 FUNCTION is_jobq RETURN BOOLEAN;
132
133
134 END;