我在DBMS_JOB.SUBMIT的帮助下将一些作业插入作业队列。
无论如何我在下一步使用DBMS_JOB.RUN在后台运行它们吗?
我不希望用户等待DBMS_JOB.RUN。
谢谢!
答案 0 :(得分:2)
您可以使用DBMS_SCHEDULER创建作业:
BEGIN
-- Job defined entirely by the CREATE JOB procedure.
DBMS_SCHEDULER.create_job (
job_name => 'YourJobName',
job_type => 'PLSQL_BLOCK',
job_action => 'BEGIN NULL; /* Your code here*/ END;',
start_date => SYSTIMESTAMP, // run the job as soon as possible
repeat_interval => NULL, // don't repeat the job
end_date => NULL, // ignore this if its not a repeating job
enabled => TRUE,
comments => 'Your comments on and description of the job.');
END;
/
您还可以更改job_type
以调用存储过程或外部可执行文件以及PL / SQL块。
如果您想查看当前正在运行的作业,可以使用:
SELECT JOB_NAME, STATE
FROM USER_SCHEDULER_JOBS;
如果你想view a log of your jobs,那么你可以使用:
SELECT *
FROM USER_SCHEDULER_JOB_LOG
ORDER BY LOG_DATE DESC;
和
SELECT *
FROM USER_SCHEDULER_JOB_RUN_DETAILS
ORDER BY LOG_DATE DESC;