dbms_scheduler package系列(七)-2
執行job
Running Jobs
兩種執行方式:非同步和同步
非同步:根據schedule的配置,job會提交給job coordinator然後被job slave選中進行執行
You can schedule a job to run asynchronously based on the schedule defined when the job is created. In this case,
the job is submitted to the job coordinator and is picked up by the job slaves for execution.
---透過如下字典可查詢job執行相關資訊
SQL> select * from user_scheduler_job_run_details where rownum=1;
LOG_ID LOG_DATE OWNER JOB_NAME JOB_SUBNAME STATUS ERROR# REQ_START_DATE ACTUAL_START_DATE RUN_DURATION INSTANCE_ID SESSION_ID SLAVE_PID CPU_USED CREDENTIAL_OWNER CREDENTIAL_NAME DESTINATION_OWNER DESTINATION ADDITIONAL_INFO
---------- -------------------------------------------------------------------------------- ------------------------------ -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- ------------------------------ ---------- -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- ------------------------------------------------------------------------------- ----------- ------------------------------ ------------------------------ ------------------------------------------------------------------------------- -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- --------------------------------------------------------------------------------
1141 03-FEB-13 10.25.02.689000 PM +08:00 SCOTT ZXY_JOB FAILED 27370 03-FEB-13 12.03.49.400000 PM +08:00 03-FEB-13 10.25.01.052000 PM +08:00 +000 00:00:01 1 93,5 3544 +000 00:00:00.00 ORA-27370: job slave failed to launch a job of type EXECUTABLE
ORA-27300: OS system dependent operation:accessing job scheduler service failed
ORA-27301: OS failure message: 管道的另一端上無任何程式。
ORA-27302: failure occurred at: sjsec 9
ORA-27303: additional information: 管道的另一端上無任何程式。
SQL> select * from user_scheduler_job_log where rownum=1;
LOG_ID LOG_DATE OWNER JOB_NAME JOB_SUBNAME JOB_CLASS OPERATION STATUS USER_NAME CLIENT_ID GLOBAL_UID CREDENTIAL_OWNER CREDENTIAL_NAME DESTINATION_OWNER DESTINATION ADDITIONAL_INFO
---------- -------------------------------------------------------------------------------- ------------------------------ -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- ------------------------------ ------------------------------ ------------------------------ ------------------------------ ---------------------------------------------------------------- -------------------------------- -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- --------------------------------------------------------------------------------
1141 03-FEB-13 10.25.02.380000 PM +08:00 SCOTT ZXY_JOB DEFAULT_JOB_CLASS RUN FAILED
同步執行job
Running Jobs Synchronously
1,必須執行run_job過程且設定use_current_session=true
2,可以用run_job在指定的schedule之外測試job,但每次測試不會影響failure_count和run_count,
但會記錄到run log中,如執行出錯會拋錯誤job invoker
---建立同步執行job
SQL> begin
2 dbms_scheduler.run_job(job_name => 'job_program_schedule',use_current_session => true);
3 end;
4 /
PL/SQL procedure successfully completed
---檢視同步執行job的相關資訊
SQL> select * from user_scheduler_job_run_details xs where xs.JOB_NAME='JOB_PROGRAM_SCHEDULE';
LOG_ID LOG_DATE OWNER JOB_NAME JOB_SUBNAME STATUS ERROR# REQ_START_DATE ACTUAL_START_DATE RUN_DURATION INSTANCE_ID SESSION_ID SLAVE_PID CPU_USED CREDENTIAL_OWNER CREDENTIAL_NAME DESTINATION_OWNER DESTINATION ADDITIONAL_INFO
---------- -------------------------------------------------------------------------------- ------------------------------ -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- ------------------------------ ---------- -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- ------------------------------------------------------------------------------- ----------- ------------------------------ ------------------------------ ------------------------------------------------------------------------------- -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- --------------------------------------------------------------------------------
1213 06-FEB-13 02.03.24.705000 PM +08:00 SCOTT JOB_PROGRAM_SCHEDULE SUCCEEDED 0 06-FEB-13 02.03.24.609000 PM +08:00 06-FEB-13 02.03.24.609000 PM +08:00 +000 00:00:00 1 94,7 +000 00:00:00.00
SQL> select * from user_scheduler_job_log tl where tl.JOB_NAME='JOB_PROGRAM_SCHEDULE';
LOG_ID LOG_DATE OWNER JOB_NAME JOB_SUBNAME JOB_CLASS OPERATION STATUS USER_NAME CLIENT_ID GLOBAL_UID CREDENTIAL_OWNER CREDENTIAL_NAME DESTINATION_OWNER DESTINATION ADDITIONAL_INFO
---------- -------------------------------------------------------------------------------- ------------------------------ -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- ------------------------------ ------------------------------ ------------------------------ ------------------------------ ---------------------------------------------------------------- -------------------------------- -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- --------------------------------------------------------------------------------
1213 06-FEB-13 02.03.24.672000 PM +08:00 SCOTT JOB_PROGRAM_SCHEDULE DEFAULT_JOB_CLASS RUN SUCCEEDED REASON="manually run"
---測試在指定schedule之外測試run_job是否影響
SQL> begin
2 dbms_scheduler.create_job(job_name=>'job_schedule',schedule_name=>'my_schedule');
3 end;
4 /
--報錯說明要指定job_type及job_action,即具體執行的指令碼相關資訊
begin
dbms_scheduler.create_job(job_name=>'job_schedule',schedule_name=>'my_schedule');
end;
ORA-06550: line 3, column 1:
PLS-00306: wrong number or types of arguments in call to 'CREATE_JOB'
ORA-06550: line 3, column 1:
PL/SQL: Statement ignored
SQL>
SQL>
SQL> ed
SQL>
---建立指定schedule的job
SQL> begin
2 dbms_scheduler.create_job(job_name=>'job_schedule',job_type=>'stored_procedure',job_action=>'proc_arg',schedule_name=>'my_schedule');
3 end;
4 /
PL/SQL procedure successfully completed
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/9240380/viewspace-754466/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- dbms_scheduler package系列(七)-1Package
- dbms_scheduler package系列(六)Package
- dbms_scheduler package系列(五)Package
- dbms_scheduler package系列(四)Package
- dbms_scheduler package系列三Package
- dbms_scheduler package系列(二)Package
- dbms_scheduler package系列(一)Package
- dbms_scheduler package body INVALID 解決方案Package
- JAVA學習之路 (七) package包管理JavaPackage
- dart系列之:建立Library packageDartPackage
- Dubbo系列之 (七)網路層那些事(2)
- 2-2 Go語言的包(package)GoPackage
- Oracle DBMS_SCHEDULEROracle
- HTB系列之七:BastardAST
- angularJS 系列(七)---指令AngularJS
- Java NIO系列教程(七) FileChannelJava
- not an rpm package (or package manifest):Package
- not an rpm package (or package manifest)Package
- packagePackage
- 使用oracle dbms_scheduler代替crontabOracle
- dbms_scheduler 相關資料
- JAVA NIO 翻譯系列(七、FileChannel)Java
- Package Specification 和 Package Body 及 Package有什麼區別? (轉)Package
- rh131筆記---unit2-package management筆記Package
- 深入安卓Package Manager和Package Installer安卓Package
- Oracle定時任務dbms_schedulerOracle
- AQS系列(七)- 終篇:AQS總結AQS
- JVM系列(七) – JVM線上監控工具JVM
- Pytorch系列:(七)模型初始化PyTorch模型
- JVM系列(七) - JVM線上監控工具JVM
- 分散式系列七: zookeeper簡單用法分散式
- jvm系列(七):jvm調優-工具篇JVM
- create table進階學習系列(七)
- 建立packagePackage
- Package ssh is not available, but is referred to by another package 錯誤PackageAI
- ElasticSearch系列2Elasticsearch
- oracle排程程式作業dbms_schedulerOracle
- oracle使用DBMS_SCHEDULER排程作業Oracle