Oracle新增job定時執行儲存過程

2021-05-21 14:01:15 字數 2333 閱讀 4687

1

、建立儲存過程(

刪除臨時表)

createorreplaceproceduresp_gs_clear_temp_tablesis

tmp_tbl_namevarchar(

30);

sqltextvarchar(

255);

cursorcur_tmp_tablesisselectobject_namefromuser_objectswhereobject_namelike'tmp%'

andlength(object_name) >

13andobject_type =

'table'

andcreated < (sysdate-2);

begin

opencur_tmp_tables;

fetchcur_tmp_tablesintotmp_tbl_name;

loop

exitwhennotcur_tmp_tables%found;

sqltext :=

'drop table '

|| tmp_tbl_name;

executeimmediatesqltext;

fetchcur_tmp_tablesintotmp_tbl_name;

endloop;

closecur_tmp_tables;

endsp_gs_clear_temp_tables;

2

、建立job

sql> variable job1 number;

sql> begin

2dbms_job.submit(:job1,'sp_gs_clear_temp_tables;', sysdate,'sysdate+1/1440');

3end;

4/pl/sql procedure successfully completed

3

、執行job

sql> begin

2dbms_job.run(:job1);

3end;

4/pl/sql procedure successfully completed

4

、刪除job

sql> begin

2dbms_job.remove(:job1);

3end;

4/pl/sql procedure successfully completed

5

、計畫任務執**況監控

select * from user_jobs;--

檢視排程任務

select * from dba_jobs_running;--

檢視正在執行的排程任務

select * from dba_jobs;--

檢視執行完的排程任務

oracle 建立job定時執行任務

先建立乙個儲存過程 例如 清空乙個表 定義好自己的job declare job1 number begin dbms job.submit job1,pro job delete sysdate,trunc sysdate 1 每天清楚記錄 end 找到你的job,找到對應的job值 select...

JOB的建立,定時,執行

來自 建表 1 2 3 4 5 create table test job para date date commit insert into test job values sysdate commit select from test job 建立儲存過程 1 2 3 4 create or r...

oracle 建立儲存過程 在job 定時執行

一 建立儲存過程。create or replace procedure upd pickup weight is begin update hk delivercost detail deltdetl set deltdetl.pickup weight select nvl hkpictdetl...