job-oracle定时任务

CREATE OR REPLACE PACKAGE BODY pkg_mng_user_app_table IS

  /*+====================================================================
存储过程
  名    称:pkg_mng_widget_table
  创建日期:2015-07-08
  内容摘要:初始化门户用户菜单
  调    用:无
  被调用  :无
  创建者  :
  被访问表:
  被更新表:
  输    入:无
  输    出:
  监控输出表:
  =================================================================+*/

  PROCEDURE sp_mng_user_app_table(pn_month_id NUMBER) IS
  BEGIN

    begin

      --查询新增人员
      for c in (select b.user_id from fa_mainaccount b 
                       left join EIP_USER_APP c on b.user_id=c.user_id 
                       left join eip_user_platform d on b.user_id=d.user_id
                       where d.user_id is not null
                       group by b.user_id having count(*)=1) loop
        
        BEGIN

          --插入菜单内容
          for st in (select *
                       from fa_resource
                      where res_type = 4
                        and res_full_name not in ('协同管理平台', '我要申请') and enable_flag='Y' ) loop
            BEGIN
              insert into EIP_USER_APP
                (APP_ID,
                 APP_TYPE,
                 USER_ID,
                 RES_ID,
                 ORDERNUMB,
                 LAST_UPDATED_DATE,
                 LAST_UPDATED_BY,
                 Created_Date,
                 Created_By,
                 ENABLE_FLAG,
                 VALIDITY_FLAG)
              values
                (seq_EIP_USER_APP.Nextval,
                 '0',
                 c.user_id,
                 st.res_id,
                 nvl(st.ordernumb,''),
                 sysdate,
                 '-1',
                 sysdate,
                 '-1',
                 'Y',
                 'Y');
                 commit;
            end;
          end loop;

        END;
      end loop;

    END;

  end;
END pkg_mng_user_app_table;


 ==================================================
job定时任务执行存储过程
begin
  sys.dbms_scheduler.create_job(job_name        => 'job_pkg_mng_user_app_table',
                                job_type        => 'PLSQL_BLOCK',
                                job_action      => 'begin pkg_mng_user_app_table.sp_mng_user_app_table('''');end;',
                                start_date      => to_date('24-03-2016 01:00:00',
                                                           'dd-mm-yyyy hh24:mi:ss'),
                                repeat_interval => 'Freq=hourly;Interval=1',
                                enabled         => true,
                                auto_drop       => true,
                                comments        => '');
end; 

猜你喜欢

转载自blog.csdn.net/sunmingf/article/details/52770786