oracle資料庫儲存過程及任務呼叫

2021-12-30 12:34:50 字數 2595 閱讀 8010

oracle資料庫儲存過程及任務呼叫

在oracle資料庫中,可以通過建立dbms作業的方式進行定時儲存過程的呼叫,但是如何

建立呢?雖然網上有一些資料,但是語法還是比較'奇葩',試了很多遍才弄好,具體情況

看就可以了。  www.2cto.com  

輸入要在作業中執行的plsql :procedure_statistic_result; /*****(儲存過程名稱,多個可以用

分號隔開,本例只有乙個)*****/

開始日期:trunc(sysdate) + 22/24;/*本日的22點執行第一次*/

下一日期:trunc(sysdate) + 22/24+1;//下乙個日期的22點執行

oracel 儲存過程:  www.2cto.com  

sql**  

create or replace  

procedure procedure_statistic_result as   

result varchar2(100);--執行結果  

v_count integer := 0;  

v_rownum integer := 0;  

cursor sdyz_cursor is select w.shengdaoyuzhong,count(w.movie_id) as moviecount from v_programlayer_sdyz w , movie b where w.movie_id = b.movie_id  group by w.

shengdaoyuzhong;  

cursor zmyz_cursor is select w.zimuyuzhong,count(w.movie_id) as moviecount from

v_programlayer_zmyz w , movie b where w.movie_id = b.movie_id  group by w.zimuyuzhong;  

begin  

/**--------------------------聲道語種統計----------------------------**/  

select count (1) into v_count from t_result_statistic t where t.resulttype = 'sheng

daoyuzhong';  

if v_count > 0 then  

delete from t_result_statistic t where t.resulttype = 'shengdaoyuzhong';       

end if ;  

for sdyz in sdyz_cursor loop  

insert into t_result_statistic (id,createdate,moviecount,yuzhong,resulttype) values (sys_guid(),sysdate,sdyz.moviecount,sdyz.shengdaoyuzhong,'shengdaoyuzhong');  

v_rownum := v_rownum+1;  

if mod(v_rownum,500) = 0 then  

commit;  

end if;  

end loop ;  

/**-----------------------字幕語種統計-----------------------**/  

select count(1) into v_count from t_result_statistic t where t.resulttype =

'zimuyuzhong';  

if v_count > 0 then  

delete from t_result_statistic t where t.resulttype = 'zimuyuzhong';       

end if ;  

v_rownum := 0;  

for zmyz in zmyz_cursor  

loop  

insert into t_result_statistic (id,createdate,moviecount,yuzhong,

resulttype) values (sys_guid(),sysdate,zmyz.moviecount,zmyz.zimuyuzhong,

'zimuyuzhong');  

v_rownum := v_rownum+1;  

if mod(v_rownum,500) = 0 then  

commit;  

end if;  

end loop ;  

if v_rownum >0 then  

commit;  

end if;  

result := 'success';  

dbms_output.put_line(result);  

exception  

when others then   

result := 'error';  

dbms_output.put_line(result);  

end procedure_statistic_result;  

Oracle資料庫儲存過程

建立語句 create or replace procedure 儲存過程名 儲存過程名定義 包括儲存過程名和引數列表。引數名和引數型別。引數名不能重複,引數傳遞方式 in,out,in out in 表示輸入引數,按值傳遞方式。out 表示輸出引數,可以理解為按引用傳遞方式。可以作為儲存過程的輸出...

oracle資料庫 儲存過程

儲存過程 stored procedure 是一組為了完成特定功能的sql 語句集,經編譯後儲存在資料庫中。使用者通過指定儲存過程的名字並給出引數 如果該儲存過程帶有引數 來執行它。儲存過程是資料庫中的乙個重要物件,任何乙個設計良好的資料庫應用程式都應該用到儲存過程。儲存過程是由流控制和sql 語句...

匯出oracle資料庫儲存過程

專案結束了,想把自己寫的儲存過程匯出儲存乙份就寫了這麼乙個簡單的指令碼,拿出來給大家共享一下。其實很簡單,主要用到user procedures user source兩個檢視,大家一看就知道了。好像網上搜到的一些都不夠全面,而且零零散散,如果覺得好的話就支援一下吧,usr bin ksh prof...