標籤:The bsp create int hat commit where 定時 RoCE
//定時釋放鎖
create or replace procedure p_releaseLockJob
--執行操作的預存程序
is
begin
delete from pub_t_datalocks t where locktime < sysdate - 1/24 ; --處理超過一小時的鎖
end p_releaseLockJob ;
/
create or replace procedure p_createRLockJob
--建立任務的預存程序
is
--任務是否已被建立,若任務被建立過,則 isExist > 0
isExist number := 0;
--歸檔任務標識
jobId number;
begin
select count(*) into isExist from all_jobs j where j.what=‘p_releaseLockJob;‘;
--檢查任務是否已被建立,如果已被建立,則不做操作
if isExist = 0 then
--建立任務
dbms_job.submit(jobId, --任務標識
‘p_releaseLockJob;‘, --任務要執行的預存程序
sysdate, --任務開始時間
‘sysdate+1/24‘); -- --任務執行循環,此處指定每周執行一次,執行時間為1小時
commit;
--運行任務
dbms_job.run(jobId);
commit;
end if;
end p_createRLockJob;
/
create or replace procedure p_closeRLockJob
--刪除任務預存程序
is
--任務是否已被建立,若任務被建立過,則 isExist > 0
isExist number := 0;
jobId number;
--歸檔任務標識
begin
select count(*) into isExist from all_jobs j where j.what=‘p_releaseLockJob;‘;
--檢查任務是否已被建立,如果已被建立,則不做操作
if isExist > 0 then
--關閉任務
begin
select job into jobId from all_jobs j where j.what=‘p_releaseLockJob;‘;
dbms_job.remove(jobId);
end ;
commit;
end if;
end p_closeRLockJob;
/
call p_createRLockJob(); //啟動定時任務
call p_closeRLockJob(); //關閉定時任務
資料庫定時任務