RSS
热门关键字:  下载  cms  模版  开源  dedecms
当前位置 :| 主页 > 站长学院 > 数据库 > Oracle >

利用Oracle的Job Queue实现定时操作

来源:Blog.ChinaUnix.net 作者:未知 时间:2006-09-14 Tag: 点击:
 
利用Oracle的Job Queue实现定时操作

 

1、确保Oracle的工作模式允许启动队列管理器(SNP进程)
SVRMGRL> Alter System Enable Restricted Session;
或 SQL> Alter System Disenable Restricted Session;

利用Oracle的Job Queue实现定时操作

 

1、确保Oracle的工作模式允许启动队列管理器(SNP进程)
SVRMGRL> Alter System Enable Restricted Session;
或 SQL> Alter System Disenable Restricted Session;

2、确保Oracle已配置任务队列管理器的启动参数
initSID.ora中:
job_queue_process=n(0);(0-36)个进程
job_queue_interval=N(60);(1-3600)秒唤醒

3、将任务加入数据库的任务队列中
DBMS_JOB.Submit (
job out binary_integer, (任务号)
what in varchar2, (执行任务的名称及入参)
next_date in date, (任务执行的时间)
interval in varchar2, (任务执行的间隔。null:执行一次;sysdate+m:周期性,每隔m天执行)
no_parse in boolean
)
同时
grant execute on dbms_job to ...;

4、将要执行的任务,为存储过程等PL/SQL程序段
SQL> variable n number;
SQL> begin
2 dbms_job.submit(n, 'my_job', sysdate, 'sysdate + 1/360');
3 commit;
4 end
5 /
SQL> print :n;

5、查看Job
Table :user_jobs、dba_jobs
Column:job (任务号)
next_date (下次执行日期)
next_sec (下次执行时间)
failures (失败次数,失败16次则自动终止)
broken (终止标志,Y/N)

 


最新评论共有 0 位网友发表了评论
发表评论
评论内容:不能超过250字,需审核,请自觉遵守互联网相关政策法规。
用户名: 密码:
匿名?
注册
栏目列表