OracleSchedulerJob学习笔记
10g_调度任务

program 定义job每次运行的程序,说白了是job每次都干什么.
创建job的时候可以指定job的schedule和program,或者只指定2者之一,或是都不指定.如果都不指定,就相当于9i的job了,自定义运行时间和运行任务.下面是一些例子:
10G scheduler
EOF
[oracle@vm4 ~]$
1 创建一个program,调用第0步创建的shell脚本:C:>sqlplus system/oracle@vm4
SQL*Plus: Release 9.2.0.1.0 - Production on 星期一 10月 17 18:39:01 2005
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
连接到:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning and Data Mining options
7 comments => 'test shell script'
8 );
9 end;
10 /
PL/SQL 过程已成功完成。
2 创建一个schedule,每1小时执行1次:
SQL> begin
2 dbms_scheduler.create_schedule
3 (
4 schedule_name => 'SCHEDULE_1_HOUR',
关于Oracle的job的一些总结

6、一些必要的参数
修改initsid.ora参数
job_queue_processes = 4
job_queue_interval = 10
job_queue_keep_connections=true
修改可执行作业个数为20个
ALTER SYSTEM SET JOB_QUEUE_PROCESSES = 20
修改取消限制模式
ALTER SYSTEM DISABLE RESTRICTED SESSION;
7、两个必要的表
user_jobs及dba_jobs_running
8、相关的几个JOB操作
删除job:dbms_job.remove(jobno);
修改要执行的操作:job:dbms_job.what(jobno,what);
时间
-------------------
2001/01/07 23:51:21
2001/01/07 23:52:22
2001/01/07 23:53:24
5、删除JOB
SQL> begin
2 dbms_job.remove(:job1);
3 end;
4 /
insert into agri_exhibition_basecur (messid,title,type,pub_date) select id,title,sort,pub_date from agri_message where (trunc(sysdate-pub_date)=0 and rownum<6) and sort='求' ;
修改下次执行时间:dbms_job.next_date(job,next_date);
oracle 作业计划

oracle 作业计划
Oracle作业计划是指在Oracle数据库中安排和管理定期执行
的任务或作业。
这些作业可以是数据库维护任务、数据备份任务、
报表生成任务等。
以下是关于Oracle作业计划的一些方面的详细解释:
1. 作业类型,Oracle作业可以分为多种类型,包括备份和恢复、性能优化、数据清理、统计信息收集等。
每种类型的作业都有
不同的特点和执行频率。
2. 作业调度,Oracle作业计划可以通过Oracle Scheduler来
进行调度和管理。
Oracle Scheduler提供了灵活的调度功能,可以
根据作业的执行时间、频率、依赖关系等进行配置。
3. 作业参数,在创建作业计划时,可以指定一些参数,如作业
的执行时间、执行频率、作业的优先级、作业的依赖关系等。
这些
参数可以根据实际需求进行配置,以确保作业能够按时、按需执行。
4. 监控和日志,Oracle作业计划提供了监控和日志功能,可
以实时查看作业的执行情况和日志信息,以便及时发现和解决问题。
5. 安全性,在配置作业计划时,需要考虑安全性因素,确保作业的执行不会对数据库的安全性造成影响。
可以通过合理的权限管理和作业执行策略来保证作业的安全性。
总之,Oracle作业计划是数据库管理中非常重要的一部分,合理的作业计划可以有效地提高数据库的运行效率和数据的安全性。
通过灵活的调度、合理的参数配置和及时的监控,可以确保作业按时、按需地执行,从而保证数据库的稳定和安全运行。
OracleJob学习--两种不同Job使用区别

OracleJob学习--两种不同Job使⽤区别1.两种不同的JobOracle中有两种建⽴Job的⽅式:1)建⽴user_job定时任务declarejob number;BEGINDBMS_JOB.SUBMIT(JOB => job, /*⾃动⽣成JOB_ID*/WHAT => 'proc_add_test;', /*需要执⾏的存储过程名称或SQL语句*/NEXT_DATE => sysdate+3/(24*60), /*初次执⾏时间-下⼀个3分钟*/INTERVAL => 'trunc(sysdate,''mi'')+1/(24*60)' /*每隔1分钟执⾏⼀次*/);commit;end;执⾏之后可以通过:select * from user_jobs;2)通过调度器建⽴定时任务 begin sys.dbms_scheduler.create_job(job_name => 'job_name', job_type => 'PLSQL_BLOCK', job_action => 'declare PRM_ERRCODE number; PRM_ERRMSG varchar2(200); begin proc_add_test(PRM_ERRCODE,PRM_ERRMSG); end;', start_date => to_date('01-04-2021 00:00:00', 'dd-mm-yyyy hh24:mi:ss'), repeat_interval => 'Freq=Monthly;Interval=1', end_date => to_date(null), job_class => 'DEFAULT_JOB_CLASS', enabled => true, auto_drop => true, comments => '测试job'); end;2.两种Job定时任务的不同之处1)两种Job都可以调⽤已有的存储过程进⾏定时执⾏。
OracleJob的使用(定时执行)

OracleJob的使⽤(定时执⾏)oracle中的job能为你做的就是在你规定的时间格式⾥执⾏存储过程,定时执⾏⼀个任务。
下⾯是⼀个⼩案例,定时每15分钟向⼀张表插⼊⼀条数据⼀1.创建⼀张测试表-- Create tablecreate table A8(a1 VARCHAR2(500))tablespace DSP_DATApctfree 10initrans 1maxtrans 255storage(initial 64Knext 1Mminextents 1maxextents unlimited);2.创建存储过程实现向测试表插⼊数据create or replace procedure proc_add_test asbegininsert into a8 values (to_char(sysdate, 'yyyy-mm-dd hh:mi'));/*向测试表插⼊数据*/commit;end;3.创建job定时任务实现⾃动调⽤存储过程(当前时间 17:03)declarejob number;BEGINDBMS_JOB.SUBMIT(JOB => job, /*⾃动⽣成JOB_ID*/WHAT =>'proc_add_test;', /*需要执⾏的存储过程名称或SQL语句*/NEXT_DATE => sysdate+3/(24*60), /*初次执⾏时间-下⼀个3分钟*/INTERVAL =>'trunc(sysdate,''mi'')+1/(24*60)'/*每隔1分钟执⾏⼀次*/);commit;end;4.也就是应该从17:06开始每隔1分钟执⾏⼀次存储过程下⾯是截⽌17:12分的测试表的数据⼆1.可以通过查询系统表查看该job信息select*from user_jobs;2.⼿动sql调⽤job (直接调⽤job可以忽略开始时间)beginDBMS_JOB.RUN(40); /*40 job的id*/end;3.删除任务begin/*删除⾃动执⾏的job*/dbms_job.remove(40);end;4.停⽌jobdbms.broken(job,broken,nextdate);dbms_job.broken(v_job,true,next_date); /*停⽌⼀个job,⾥⾯参数true也可是false,next_date(某⼀时刻停⽌)也可是sysdate(⽴刻停⽌)。
【Oracle学习笔记】定时任务(dbms_job)

【Oracle学习笔记】定时任务(dbms_job)⼀、概述Oralce中的任务有2种:Job和Dbms_job,两者的区别有:1. jobs是oracle数据库的对象, dbms_jobs只是jobs对象的⼀个实例,就像对于tables, emp和dept都是表的实例。
2.创建⽅式也有差异,Job是通过调⽤dbms_scheduler.create_job包创建的,Dbms_job则是通过调⽤dbms_job.submit包创建的。
3.两种任务的查询视图都分为dba和普通⽤户的,Job对应的查询视图是dba_scheduler_jobs和user_scheduler_jobs,dbms_jobs对应的查询视图为dba_jobs和user_jobs。
这⾥主要是介绍Dbms_job。
⼆、使⽤1、创建job:1BEGIN2 DBMS_JOB.SUBMIT(3 JOB OUT BINARY_INTERGER,--输出变量,是此任务在任务队列中的编号,也可以⾃定义,⼀般不传4 WHAT IN VARCHAR2,--执⾏的任务的名称及其输⼊参数5 NEXT_DATE IN DATE DEFAULT SYSDATE,--任务执⾏的时间6 INTERVAL IN VARCHAR2DEFAULT NULL,--任务执⾏的时间间隔7 NO_PARSE IN BOOLEAN DEFAULT FALSE,--⽤于指定是否需要解析与作业相关的过程8 INSTANCE IN BINARY_INTEGER DEFAULT ANY_INSTANCE,--⽤于指定哪个例程可以运⾏作业9 FORCE IN BOOLEAN DEFAULT FALSE--⽤于指定是否强制运⾏与作业相关的例程10 );11END新⼿可以使⽤窗⼝创建:2、删除job: dbms_job.remove(jobno); -- jobno任务号3、修改要执⾏的操作: job:dbms_job.what(jobno, what); --指定任务号以及存储过程4、修改下次执⾏时间:dbms_job.next_date(jobno, next_date); --指定任务号的时间5、修改间隔时间:dbms_job.interval(jobno, interval); --指定任务号的间隔时间6、改变与作业相关的所有信息,包括作业操作,作业运⾏⽇期以及运⾏时间间隔等.1 dbms_job.change(2 job in binary_integer,3 what in varchar2,4 next_date in date,5 interval in varchar2,6 instance in binary_integer default null,7 force in boolean default false8 );例⼦:dbms_job.change(2,null,null,'sysdate+2');6、启动job: dbms_job.run(jobno); --指定任务号启动7、停⽌job: dbms.broken(jobno, broken, nextdate); –broken为boolean值 N代表启动,Y代表没启动(STOP)三、Interval 说明间隔/interval是指上⼀次执⾏结束到下⼀次开始执⾏的时间间隔,当interval设置为null时,该job执⾏结束后,就被从队列中删除。
oracle 计划任务

Oracle计划任务博客分类:OracleOracle在10g版本以前,计划任务用的是DBMS_JOB包,10g版本引入DBMS_SCHEDULER来替代先前的DBMS_JOB,在功能方面,它比DBMS_JOB提供了更强大的功能和更灵活的机制管理。
一、 DBMS_JOB1、查看数据库中定时任务的最多并发数,一般设置为102、设置数据库中定时任务的最多并发数,如果设置为0,那么数据库定时作业是不会执行的。
Sql代码3、Job的使用说明:4、创建Job事例1:Job执行间隔时间的Interval参数说明Sql代码5、创建Job事例2:其中最后一个参数'sysdate+1/1440'表示时间间隔为每分钟。
其它常用的时间间隔的设置如下:(1)如果想每天凌晨1点执行,则此参数可设置为'trunc(sysdate)+25/24';(2)如果想每周一凌晨1点执行,则此参数可设置为'trunc(next_day(sysdate,1))+25/24';(3)如果想每月1号凌晨1点执行,则此参数可设置为'trunc(last_day(sysdate))+25/24';(4)如果想每季度执行一次,则此参数可设置为'trunc(add_months(sysdate,3),'Q')+1/24';(5)如果想每半年执行一次,则此参数可设置为'add_months(trunc(sysdate,'yyyy'),6)+1/24';(6)如果想每年执行一次,则此参数可设置为'add_months(trunc(sysdate,'yyyy'),12)+1/24'。
6、Job调度任务查看操作7、Job其它操作(1)启动运行JobSql代码(2)删除job: dbms_job.remove(jobno);(3)修改要执行的操作job: dbms_job.what(jobno,what);(4)修改下次执行时间:dbms_job.next_date(job,next_date);(5)修改间隔时间: dbms_job.interval(job,interval);(6)停止job: dbms.broken(job,broken,nextdate);二、DBMS_SCHEDULER1、 DBMS_SCHEDULER的功能更强大,定义更灵活,增强了与系统的交互性。
Job Scheduler Oracle FLEXCUBE 大纲与说明说明书

Job Scheduler Oracle FLEXCUBE Universal BankingRelease 11.3.83.02.0[April] [2014] Oracle Part Number E53607-01Job SchedulerTable of Contents1.ABOUT THIS MANUAL................................................................................................................................1-1 1.1I NTRODUCTION...........................................................................................................................................1-11.1.1Audience............................................................................................................................................1-11.1.2Acronyms and Abbreviations.............................................................................................................1-11.1.3Glossary of Icons...............................................................................................................................1-12.JOB SCHEDULING........................................................................................................................................2-1 2.1I NTRODUCTION...........................................................................................................................................2-1 2.2D EFINING J OBS...........................................................................................................................................2-1 2.3S CHEDULING J OBS......................................................................................................................................2-4 2.4C ONTROLLING J OBS...................................................................................................................................2-5 2.5N OTIFICATION P ROCESS.............................................................................................................................2-6 2.6V IEWING N OTIFICATION P ARAMETERS.....................................................................................................2-10 2.7EMS P ROCESS WITH SCHEDULING ARCHITECTURE...................................................................................2-112.7.2Approach.........................................................................................................................................2-113.SCREEN GLOSSARY....................................................................................................................................3-1 3.1F UNCTION ID L IST......................................................................................................................................3-11. About this Manual 1.1 IntroductionThis manual is designed to help acquaint you with the Job scheduling process in OracleFLEXCUBE.1.1.1 AudienceThis manual is intended for the following User/User Roles:Role FunctionBack office data entry Clerks Input functions for maintenance related to the interface.Back office Managers/Officers Authorization functions.1.1.2 Acronyms and AbbreviationsAbbreviation DescriptionSystem Unless and otherwise specified, it shall always refer to Oracle FLEXCUBEsystem1.1.3 Glossary of IconsThis User Manual may refer to all or some of the following icons.Icons FunctionNewCopySaveDeleteUnlockPrintCloseRe-openReverseTemplateIcons FunctionRoll-overHoldAuthorizeLiquidateExitSign-offHelpAdd rowDeleterowOptionListConfirmEnterQueryExecuteQueryRefer the Procedures User Manual for further details about the icons.2. Job Scheduling 2.1 IntroductionJob scheduling is the process where different tasks get executed at pre-determined time or when the right event happens. A job scheduler is a system that can be integrated with other softwaresystems for the purpose of executing or notifying other software components when a pre-determined, scheduled time arrives. The two types of job schedulers used in Oracle FLEXCUBE FCJ architecture are as follows:∙Quartz - provides scheduler interface to enable operations such as scheduling and un-scheduling of jobs and starting, stopping, pausing the scheduler∙Flux - software component used for performing enterprise job scheduling2.2 Defining JobsA job is a business activity which the system performs repeatedly on timely basis. OracleFLEXCUBE enables you to define a job and schedule it using ‘Job Maintenance’ screen. You can invoke this screen by typing ‘STDJOBMT’ in the field at the top right corner of the Application tool bar and clicking on the adjoining arrow button.You can specify the following fields in this screen.Job CodeSpecify the unique code to identify the Job.Job DescriptionSpecify a brief description of what the job is supposed to do.Job GroupSpecify the job group name to represent the same group of jobs for identification.Job TypeSelect the type of job from the drop-down list. The following options are available for selection: ∙PL/SQL∙JAVAMax Number InstancesSpecify the maximum number of instances that needs to be queued up.ExampleIf a job runs for more than the duration defined, the next instance of the same job will be ready for processing. This parameter defines the job’s behavior in such cases,If you maintain the job as ‘STATEFUL’, then the number of such missed instances will be queued up so that it would start executing once this long running job ends. This field specifies the number of such job instances that needs to be queued up.If you maintain the job as ‘STATELESS’, it indicates the number of threads that can be executed in parallel. If you maintain the max number instances as ‘0’,no instances are queued or parallel processed till the current running instance is completed.SchedulerSpecify the name of the scheduler. The system defaults the name to ‘SchedulerFactory’. However, you can modify this name. This signifies the scheduler name which is configured as part of infra.Trigger TypeSelect the type of the trigger from the drop-down list. The following options are available: ∙Simple - Interval based jobs.(i.e., every one hour)∙Cron - Time based jobs.(i.e., Friday 4:30PM)Scheduler TypeSelect the type of scheduler from the drop-down list. The following options are available: ∙Quartz∙FluxPrioritySelect the priority on which the system should execute the jobs in the scheduler from the drop-down list. The following options are available.∙Normal∙HighIf two jobs with different priorities fire at the same time, then system gives preference to the job with higher priority.Message QueueSpecify the default JMS queue to which a job needs to send message. You can specify this only if the job has to send messages to JMS.Cron ExpressionSpecify the corresponding Cron expression for a job with trigger type as ‘Cron’. You need to do this to determine the time and interval of job firing.Class or ProcedureSpecify the Java class file name if job type is ‘Java’ or the PL/SQL procedure name if the job type is ‘PL/SQL’. This denotes which java class or pl/sql procedure the system should call when a job fires.Number of SubmissionsSpecify the number of times a job can fire before it is unscheduled from scheduler. This applies only to trigger types maintained as ‘Simple’.IntervalSpecify the time interval between jobs. This applies only to trigger types maintained as ‘Simple’. Trigger ListenerSpecify a java class as a trigger listener which will be notified of events such as before job fired, after job completed, misfired jobs.ActiveCheck this box to set the job as active. The scheduler does not pick the inactive jobs for scheduling.Ds NameSpecify the name of the database schema to which the job has to connect. This attribute is used in case of multi instance deployment of Oracle FLEXCUBE application.Logging RequiredCheck this box to indicate that system should log each firing of job. This helps in logging the firing time of job and key log info as part of that firing. This also enables tracking of each job’s firing times and helps in identifying miss-fired jobs.Startup ModeSpecify start up mode of the job from the drop-down list. The following options are available: ∙Auto - The job starts automatically when Oracle FLEXCUBE application starts∙Manual - You should start the job manually in job controller by resuming the job.Parameter DetailsYou can specify the job specific parameters, which are passed to job class or procedure atruntime. The following details are captured here:Parameter NameSpecify the name of the job parameter. The parameter name you specify here is passed to job class or procedure at run time.Data TypeSpecify the data type of the parameter.Parameter ValueSpecify the value of the parameter.2.3 Scheduling JobsAll jobs for scheduling are stored in a static data store and each job is associated with a name indicating where the job has to execute. Jobs are created in the Application Server and arescheduled based on this data.The job name should be unique across the schedulers available in the system.When the application server starts, the job details from static data store will get cached. These cached jobs will then be scheduled using either the quartz or flux scheduler.For example, the notification process can be handled by the job schedulers as follows:1. When a contract is created in Oracle FLEXCUBE, a database level trigger acting on thecontract main table inserts details like base table name, primary key fields, primary keyvalues and branch code into a notification log table and sets the process status of theinserted record as ‘U’ (unprocessed).2. The scheduled job polls the notification log table for unprocessed records and validateswhether notification is required.3. If notification is not required, then the process status is set to ‘N’ (not required) in notificationlog table.4. If notification is required then notifications are sent to the respective destination and theprocess status of the record is changed to ‘P’ (Processed) in notification log table.2.4 Controlling JobsThe details of jobs that are scheduled can be viewed using the ‘Job Details’ screen. In this screen you can pause or resume a job that has been scheduled. You can invoke the ‘Job Details’ screen by typing ‘SMSJOBBR’ in the field at the top right corner of the Application tool bar and clickingthe adjoining arrow button.You can a search for a scheduled job by specifying any of the following:Job NameSelect the name of the job that you want to search for from the option list provided.StateSelect the state of the job you want to search for from the option list provided. The followingoptions are possible for Quartz schedulers:∙Acquired∙Waiting∙Blocked∙PausedFor Flux schedulers, the options are as follows:∙Firing∙Waiting∙PausedSchedulerSelect the scheduler to which the job you want to search for has been assigned.Job GroupSelect the group to which the job you want to search for belongs, from the option list provided.Next Fire TimeSelect the time when the job is scheduled to be run next.Click ‘Search’ button to view the details related to the job. You can pause a job by selecting it and clicking the ‘Pause’ button.You can resume a paused job by clicking ‘Resume’ button and the job is scheduled for its nextfire time.A job can take any of the following states.∙COMPLETE - This indicates that the trigger does not have remaining fire-times in its schedule.∙NORMAL - This indicates that the trigger is in the "normal" state.∙BLOCKED - A job trigger arrives at the blocked state when the job that it isassociated with is a ‘Stateful’ job and it is currently executing.∙PAUSED - This indicates that the job is manually paused from executing.∙ERROR - A job trigger arrives at the error state when the scheduler attempts to fire it, but cannot due to an error creating and executing its related job. Also, a job arrives atERROR state when the associated class for the job is not present in class path. 2.5 Notification ProcessThe notification process is in two layers. In the first layer the notification process as part of jobs in FCJ scheduler sends minimal data required for notification to an internal JMS queue. In thesecond layer the notification process as part of an MDB that listens on internal JMS queue builds final notifications and sends them to their intended destinations.The Notification Process in Oracle FLEXCUBE using the jobs scheduler is as follows:1. The trigger on the base table inserts key details into a static notification log table instead ofOracle AQ.2. Once Job is triggered, a request is sent to EJB layer from job execution class and thenotification log table is polled for unprocessed records.3. Each unprocessed record is locked.4. The record is verified against the notification maintenance and checked whether notificationis to be sent or not.5. If notification is to be sent, pre notification message xml is built and it is sent to internalnotify_queue(JMS queue).6. The job is then rescheduled to fire next time based on the previous execution.The notification process in MDB is as follows:7. The Notification MDB listens on the internal notify JMS queue.8. On any message received, the MDB identifies which schema to connect using the JNDIname being present as part of the message xml.9. Gateway notification processing package is called from MDB in order to build the actualnotifications.10. In MDB the notifications built is processed and sent to the destination specified incorresponding notification.11. In case of any exception the whole transaction is rolled back.12. If all notifications are successfully processed then transaction is committed.The flow chart of notification process in scheduler:The flow chart for notification process in MDB:2.6 Viewing Notification ParametersYou can view and amend certain notification parameters in Oracle FLEXCUBE using ‘Gateway Notification Maintenance’ screen. You can invoke this screen by typing ‘IFDNOTIF’ in the field at the top right corner of the Application tool bar and clicking on the adjoining arrow button.Notification CodeThe system displays a unique code to identify a notification.DescriptionThe system displays a brief description of the notification. However, you can modify thedescription in this screen.OperationSelect the type of operation for the notification from the following.∙Insert - to indicate a new operation of notification function∙Update - To indicate a modification operation of notificationGateway OperationSpecify the gateway operation name to execute query for the mentioned service.Gateway ServiceSpecify the gateway service to be used to get the full screen response.IO Request NodeSpecify the gateway IO request node to be used in querying operation.Specific NotificationCheck this box to indicate the system to send specific notification. The system handles anydeviation from generic notification process by creating specific triggers once you check this field.Full Screen Reply RequiredCheck this box to indicate that the full screen notification response has to be sent. Otherwise, the primary key response notification is sent.Head OfficeCheck this box to send notification only from head office.2.7 EMS Process with scheduling architecture2.7.1.1 The new EMS Process:Incoming EMS ProcessA job is scheduled to poll the incoming folder on timely basis. Once a message is received in thefolder, the job picks the message and sends it to an internal JMS queue. An MDB listening on the queue will read the message and identifies the media and processes the message.Outgoing EMS ProcessA job is scheduled to poll the outgoing messages that are generated but not handed off. Eachmessages polled will be sent to an internal JMS queue.A MDB, acting upon the internal JMS queue will pick the message from queue and sends themessage to appropriate destination (Folder, or e-mail, or JMS queue).2.7.2 ApproachThe Outgoing EMS Process happens in two layers.1. The EMS process as part of jobs in FCJ scheduler, polls the outgoing message table ofFLEXCUBE for generated and un-send messages. The job then sends minimal data about themessage to be handed off, to an internal JMS queue.2. The EMS process as part of an MDB that listens on internal JMS queue to build final messageand to send to their intended destinations.The Incoming EMS Process happens in two layers.1. The EMS process as part of jobs in FCJ scheduler, which polls the pre configured folder formessages and sends the messages read, to EMS internal queue.2. The EMS process as part of an MDB, that listens on internal JMS queue identifies the messagefrom queue and calls the incoming messages service package in backend to process themessage. Additionally, the MDB can be made an independent unit to listen on external JMS toprocess incoming messages.The Incoming EMS Process as part of jobs scheduler is as follows:1. Once job is triggered, it polls for messages in a folder(Configured for incoming messages).2. Each message is then sent to an internal JMS queue.3. The job is then rescheduled to fire next time.EMS processes in MDB are as follows:1. An MDB that listens on the internal EMS incoming queue will receive the message.2. The media details are identified and incoming message processing package in backend is calledto process the message.3. In case of any exception while processing, message will be sent to a deferred queue.In case of messages directly arrive to JMS queue instead of a folder; the same MDB will beconfigured to listen on specific queue.3. Screen Glossary 3.1 Function ID ListThe following table lists the function id and the function description of the screens covered as part of this User Manual.Function ID Function DescriptionIFDNOTIF Gateway Notification MaintenanceSMSJOBBR Job DetailsSTDJOBMT Job MaintenanceJob Scheduler[April] [2014]Version 11.3.83.02.0Oracle Financial Services Software LimitedOracle ParkOff Western Express HighwayGoregaon (East)Mumbai, Maharashtra 400 063IndiaWorldwide Inquiries:Phone: +91 22 6718 3000Fax:+91 22 6718 3001/financialservices/Copyright © 2005, 2014, Oracle and/or its affiliates. All rights reserved.Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.U.S. GOVERNMENT END USERS: Oracle programs, including any operating system, integrated software, any programs installed on the hardware, and/or documentation, delivered to U.S. Government end users are ‘commercial computer software’ pursuant to the applicable Federal Acquisition Regulation and agency-specific supplemental regulations. As such, use, duplication, disclosure, modification, and adaptation of the programs, including any operating system, integrated software, any programs installed on the hardware, and/or documentation, shall be subject to license terms and license restrictions applicable to the programs. No other rights are granted to the U.S. Government.This software or hardware is developed for general use in a variety of information management applications. It is not developed or intended for use in any inherently dangerous applications, including applications that may create a risk of personal injury. If you use this software or hardware in dangerous applications, then you shall be responsible to take all appropriate failsafe, backup, redundancy, and other measures to ensure its safe use. Oracle Corporation and its affiliates disclaim any liability for any damages caused by use of this software or hardware in dangerous applications.This software and related documentation are provided under a license agreement containing restrictions on use and disclosure and are protected by intellectual property laws. Except as expressly permitted in your license agreement or allowed by law, you may not use, copy, reproduce, translate, broadcast, modify, license, transmit, distribute, exhibit, perform, publish or display any part, in any form, or by any means. Reverse engineering, disassembly, or decompilation of this software, unless required by law for interoperability, is prohibited.The information contained herein is subject to change without notice and is not warranted to be error-free. If you find any errors, please report them to us in writing.This software or hardware and documentation may provide access to or information on content, products and services from third parties. Oracle Corporation and its affiliates are not responsible for and expressly disclaim all warranties of any kind with respect to third-party content, products, and services. Oracle Corporation and its affiliates will not be responsible for any loss, costs, or damages incurred due to your access to or use of third-party content, products, or services.。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
Oracle scheduler job 学习笔记
1.Scheduler增删改查操作
1.1.创建procedure
create or replace procedure aiki_test
as
begin
insert into aiki.a2 values(‘a’,88);
commit;
end;
1.2.创建scheduler job
begin
dbms_scheduler.create_job (
job_name => ‘aiki_test_name’,
job_class => ‘DEFAULT_JOB_CLASS’,
job_type => ‘STORED_PROCEDURE’,
job_action => ‘aiki_test’,
start_date => sysdate,
repeat_interval => ‘FREQ=DAILY; BYHOUR=10;BYMINUTE=18,19;’, end_date =>null,
comments => ‘系统临时测试’
);
end;
1.3.启用scheduler job
begin
dbms_scheduler.enable(‘aiki_test1’);
end;
1.4.删除scheduler job
begin
DBMS_SCHEDULER.DROP_JOB(JOB_NAME => ‘AIKI_TEST2’);
end;
1.5.查询scheduler job
select * from user_scheduler_jobs;
2.repeat_interval参数解释
2.1.描述
这个语法形式看起来复杂无比,其实实用起来很简单,之所以看起来复杂,是因为其功能太过灵活(之前的三思系列笔记中,已经阐述过灵活与复杂的关系),这里不准备逐条解释每一个语法细节,下面将着重通过一些常用设置,希望能够更有助于广大同仁的理解。
2.2.举例
1、设置任务仅在周5的时候运行:
REPEAT_INTERVAL => “FREQ=DAILY; BYDAY=FRI”;
REPEAT_INTERVAL => “FREQ=WEEKLY; BYDAY=FRI”;
REPEAT_INTERVAL => “FREQ=YEARLY; BYDAY=FRI”;
上述三条语句虽然指定的关键字小有差异,不过功能相同。
2、设置任务隔一周运行一次,并且仅在周5运行:
REPEAT_INTERVAL => “FREQ=WEEKLY; INTERVAL=2; BYDAY=FRI”;
3、设置任务在当月最后一天运行:
REPEAT_INTERVAL => “FREQ=MONTHLY; BYMONTHDAY=-1”;
4、设置任务在3月10日运行:
REPEAT_INTERVAL => “FREQ=YEARLY; BYMONTH=MAR; BYMONTHDAY=10”;
REPEAT_INTERVAL => “FREQ=YEARLY; BYDATE=0310”;
上述两条语句功能相同。
5、设置任务每10隔天运行:
REPEAT_INTERVAL => “FREQ=DAILY; INTERVAL=10”;
6、设置任务在每天的下午4、5、6点时运行:
REPEAT_INTERVAL => “FREQ=DAILY; BYHOUR=16,17,18”;
7、设置任务在每月29日运行:
REPEAT_INTERVAL => “FREQ=MONTHLY; BYMONTHDAY=29”;
8、设置任务在每年的最后一个周5运行:
REPEAT_INTERVAL => “FREQ=YEARLY; BYDAY=-1FRI”;
9、设置任务每隔50个小时运行:
REPEAT_INTERVAL => “FREQ=HOURLY; INTERVAL=50”;
2.3.简便方式
另外,你是否在怀念常规job中设置interval的简便,虽然功能较弱,但是设置操作非常简单,无须懊恼,其实SCHEDULER中的REPEAT_INTERVAL也完全可以按照那种方式设置,前面都说了,REPEAT_INTERVAL实际上是指定周期,直接指定一个时间值,当然也是周期喽。
比如说,设置任务每天执行一次,也可以设置REPEAT_INTERVAL参数值如下:REPEAT_INTERVAL => “trunc(sysdate)+1”
又比如设置任务每周执行一次:
REPEAT_INTERVAL => “trunc(sysdate)+7”
不过需要注意,这种方式仅用于创建SCHEDULER中jobs时使用,不能用于schedule。
日历表达式基本分为三部分: 第一部分是频率,也就是"FREQ"这个关键字,它是必须指定的; 第二部分是时间间隔,也就是"INTERVAL"这个关键字,取值范围是1-999. 它是可选的参数; 最后一部分是附加的参数,可用于精确地指定日期和时间,它也是可选的参数,例如下面这些值都是合法的:
BYMONTH,BYWEEKNO,BYYEARDAY,BYMONTHDAY,BYDAY,BYHOUR,BYMINUTE,BYSECOND。