/*编写作业*/
VARIABLE JOB NUMBER;
BEGIN
DBMS_JOB.SUBMIT(
JOB => :JOB, /*自动生成JOB_ID*/
WHAT => 'CREATE_TASK_BY_PLAN;', /*需要执行的过程或SQL语句*/
NEXT_DATE => TRUNC(SYSDATE+1)+6/24, /*初次执行时间*/
INTERVAL => 'TRUNC(SYSDATE+1)+6/24'); /*执行周期*/
COMMIT;
END;
/*这个块执行完成之后就会生成此JOB的ID
之前一直出现ORA-01008参数没有完全绑定*/
/*执行作业*/
BEGIN
DBMS_JOB.RUN(JOB_ID);
END;
/*这个块执行时曾出现作业1未完成的问题,
后来发现用户权限不足*/
--------------
drop procedure pro_delAuthInfo;
create or replace procedure pro_delAuthInfo
as
BEGIN
delete from ispace_filetransfer_auth t
where (sysdate - to_date(t.timestamp,'YYYYMMddhh24miss')) >=3/24
and t.transfertype=2 and t.delflag=1;
commit;
EXCEPTION
WHEN no_data_found THEN
dbms_output.PUT_LINE('No data.');
END;
/
-- 创建数据库定时任务
declare
jobnum number;
begin
for cur in (select t.job from user_jobs t where t.what = 'pro_delAuthInfo;')
loop
dbms_job.remove(cur.job);
end loop;
dbms_job.submit(jobnum,'pro_delAuthInfo;',sysdate,'TRUNC(SYSDATE + 1) + 1/24');
commit;
end;
/
--------------
命令行查看存储过程的内容,过程名
SELECT TEXT FROM USER_SOURCE WHERE NAME = upper('pro_delAuthInfo') AND TYPE = 'PROCEDURE' ORDER BY LINE;
查看是否有失败的数据库任务
select JOB, LAST_DATE, THIS_DATE, NEXT_DATE,BROKEN,FAILURES,WHAT from user_jobs;
VARIABLE JOB NUMBER;
BEGIN
DBMS_JOB.SUBMIT(
JOB => :JOB, /*自动生成JOB_ID*/
WHAT => 'CREATE_TASK_BY_PLAN;', /*需要执行的过程或SQL语句*/
NEXT_DATE => TRUNC(SYSDATE+1)+6/24, /*初次执行时间*/
INTERVAL => 'TRUNC(SYSDATE+1)+6/24'); /*执行周期*/
COMMIT;
END;
/*这个块执行完成之后就会生成此JOB的ID
之前一直出现ORA-01008参数没有完全绑定*/
/*执行作业*/
BEGIN
DBMS_JOB.RUN(JOB_ID);
END;
/*这个块执行时曾出现作业1未完成的问题,
后来发现用户权限不足*/
--------------
drop procedure pro_delAuthInfo;
create or replace procedure pro_delAuthInfo
as
BEGIN
delete from ispace_filetransfer_auth t
where (sysdate - to_date(t.timestamp,'YYYYMMddhh24miss')) >=3/24
and t.transfertype=2 and t.delflag=1;
commit;
EXCEPTION
WHEN no_data_found THEN
dbms_output.PUT_LINE('No data.');
END;
/
-- 创建数据库定时任务
declare
jobnum number;
begin
for cur in (select t.job from user_jobs t where t.what = 'pro_delAuthInfo;')
loop
dbms_job.remove(cur.job);
end loop;
dbms_job.submit(jobnum,'pro_delAuthInfo;',sysdate,'TRUNC(SYSDATE + 1) + 1/24');
commit;
end;
/
--------------
命令行查看存储过程的内容,过程名
SELECT TEXT FROM USER_SOURCE WHERE NAME = upper('pro_delAuthInfo') AND TYPE = 'PROCEDURE' ORDER BY LINE;
查看是否有失败的数据库任务
select JOB, LAST_DATE, THIS_DATE, NEXT_DATE,BROKEN,FAILURES,WHAT from user_jobs;