用DBMS_JOB
DBMS_JOB.SUBMIT(
job OUT BINARY_INTEGER,
what IN VARCHAR2,
next_date IN DATE DEFAULT sysdate,
interval IN VARCHAR2 DEFAULT 'null',
no_parse IN BOOLEAN DEFAULT FALSE,
instance IN BINARY_INTEGER DEFAULT any_instance,
force IN BOOLEAN DEFAULT FALSE);
job
Number of the job being run.
what
PL/SQL procedure to run.
next_date
Next date when the job will be run.
interval
Date function that calculates the next time to run the job.
The default is NULL. This must evaluate to a either a future point
in time or NULL.
no_parse
A flag. The default is FALSE. If this is set to FALSE, then Oracle parses
the procedure associated with the job. If this is set to TRUE,
then Oracle parses the procedure associated with the job the first time
that the job is run.
For example, if you want to submit a job before you have created the tables
associated with the job, then set this to TRUE.
instance
When a job is submitted, specifies which instance can run the job.
force
If this is TRUE, then any positive integer is acceptable as the job instance.
If this is FALSE (the default), then the specified instance must be running;
otherwise the routine raises an exception.
比如你的存贮过程是 myproc
那么,
declare
j integer;
begin
dbms_job.submit(j,'myproc',trunc(add_months(sysdate,1),'mm'),
'trunc(add_months(sysdate,1),''mm'')');
end;
/
下个月一号的00:00开始,每月1日的00:00执行