向oracle高手请教?如何在oracle中,建立任务?(100分)

  • 主题发起人 主题发起人 NewHuman
  • 开始时间 开始时间
N

NewHuman

Unregistered / Unconfirmed
GUEST, unregistred user!
各位大侠:
小弟,有时请教,如何在oracle中建立计划任务,也就是没隔一个时间间隔,就去执行一个
存储过程什么的?
 
用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执行


 
楼上的人兄实在太牛,我好好看看!
 
楼上的兄弟,还有一个问题请教:
如何在oracle中取得unix下的long型时间值
(即如何将一个date类型转换成unix下的整形时间),一并给您加分!
 
接受答案了.
 
后退
顶部