oracle定时任务

项目用到类型于淘宝的用户确认功能,在超过两天未确认的情况下,默认用户确认行为,在tbl_apply申请中增加一个confirm_sign作为确认字段,updateConfirm存储过程为设置处理完成后超过两天未确认的申请的确认字段为1(已确认),下面创建job(定时任务)

1.create or replace procedure updateConfirm
as begin
update tbl_apply t set t.confirm_sign=1 where ROUND(TO_NUMBER(sysdate - (select to_date(max(operate_date),'yyyy/MM/dd hh24:mi:ss') from tbl_operate_process where process_sn=t.apply_sn)))>2;
commit;
end updateConfirm;

2.variable job1 number;  /*sqlplus中执行,在plsql中无效*/

3.begin

dbms.submit(:job1,’updateConfirm;’,sysdate,’sysdate+2’);

end;

/

4.begin

dbms.run(:job);

end;

/

dbms_job

 

 

改用spring的定时器

<bean id="startQuertz"
        class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
        <property name="triggers">
            <list>
                <ref bean="runTask" /> 
            </list>
        </property>
    </bean>
    <bean id="runTask" class="org.springframework.scheduling.quartz.CronTriggerBean">
        <property name="jobDetail">
            <ref bean="jobTask" />
        </property>
        <property name="cronExpression">
            <value>0 * * * * ?</value>
        </property>
    </bean>

 

posted @ 2013-07-15 17:52  next_door_boy  Views(168)  Comments(0)    收藏  举报