动态修改oracle job 让job在指定时间执行

动态修改oracle job 让job在指定时间执行html

PROCEDURE Wsp_Call_MillAcident (
                                   an_acidentId  IN VARCHAR2,--发生事故的ID值为字符串类型
                                        at_acidentime IN VARCHAR2,--发生事故的时间精确到秒(YYYY-MM-DD HH24:MI:SS)
                                   an_preSeconds IN NUMBER,--发生事故前n秒为复数
                                        an_aftSeconds IN NUMBER--发生事故后n秒
                                   )
   AS
     strSql    varchar2(2000);
     startTime varchar2(30);
     endTime   varchar2(30);
     calltime  varchar2(30);
     acidenttime date;
     ln_preSeconds NUMBER;
     ln_aftSeconds NUMBER;
   BEGIN
      if (an_acidentId is null) then
          RETURN;
      end if;
      if (at_acidentime is null) then
         acidenttime:=sysdate;
      else
         acidenttime:=to_date(at_acidentime,'YYYY-MM-DD HH24:MI:SS');
      end if;
      if ( an_preSeconds is null ) then
         ln_preSeconds :=ACIDENT_PRE_SECONDS;
       else
         ln_preSeconds:=an_preSeconds;
      end if;
      if ( an_aftSeconds is null ) then
         ln_aftSeconds :=ACIDENT_AFT_SECONDS;
       else
         ln_aftSeconds :=an_aftSeconds;
      end if;
      
      --计算事故发生时间at_acidentime以前an_preSeconds秒的时间
      startTime :=fc_getnextsecondstime(acidenttime,ln_preSeconds); --样式'yyyy-mm-dd hh24:mi:ss'
      --计算事故发生时间at_acidentime以后an_aftSecends秒的时间
      endTime   :=fc_getnextsecondstime(acidenttime,ln_aftSeconds); --样式'yyyy-mm-dd hh24:mi:ss'
      --计算做业调用时间与endtime相同
      calltime :=endTime || ' +8:00'; --样式'2008-07-10 10:01:00 +8:00'
   
      --构造做业执行程序,将各遥测表中按以上两个计算出来的时间取值,注入到事故追忆历史表
      
      strSql :='begin 
                 insert into ACIDNT_RETROS_HIS( ID, POINT_ID, POINT_IDENTIFIER, POINT_VALUE, GET_TIME, POINT_TYPE, ACCIDENT_ID)
                 select t1.ID || systimestamp, t1.POINT_ID, t1.POINT_IDENTIFIER,t1.POINT_VALUE,t1.GET_TIME,t1.POINT_TYPE, '|| an_acidentId ||' from ACIDNT_RETROS_TEMP t1;  
                 commit;  
                end;';
       --dbms_output.put_line(startTime);
       --dbms_output.put_line(endTime);
       dbms_output.put_line(calltime);
       dbms_output.put_line(strSql);
       
       --修改做业调用属性的job_type
       dbms_scheduler.set_attribute( name => 'WINDPOWER.WIND_JOB_SGZY', attribute => 'job_type', value => 'PLSQL_BLOCK'); 
       --修改做业调用属性的job_action
       dbms_scheduler.set_attribute( name => 'WINDPOWER.WIND_JOB_SGZY', attribute => 'job_action', value => strSql );   
       --修改做业调用调度属性的start_date    
       dbms_scheduler.set_attribute( 
        name => 'WINDPOWER.WIND_JOB_SGZY', 
        attribute => 'start_date', value => to_timestamp_tz(calltime, 'YYYY-MM-DD HH24:MI:SS TZH:TZM')); 
        --修改做业调用属性使其可用
  dbms_scheduler.enable( '"WINDPOWER"."WIND_JOB_SGZY"' ); 
   END;
oracle

http://topic.csdn.net/u/20080827/09/f119d3bb-0df6-449c-9d1a-4c9e15f22f6e.htmlide