一次简单的存储过程以及定时任务设置

来源:互联网 发布:广发淘宝卡新规则 编辑:程序博客网 时间:2024/06/03 16:41
drop table checkinout
--创建表
 create table checkinout(
  userid int,
  checkTime Date,
  checkType varchar2(10),
  verifyCode int,
  sensorid varchar2(40),
  logId varchar2(40),
  MachinedId varchar2(40)
);
 commit;
-- 创建存储过程

drop procedure pro_time


create or replace procedure pro_time
is
num varchar2(40);
num1 varchar2(40);
time1 date;
time2 date;
   begin
     select trunc(dbms_random.value(232,249)) into num from dual;
     select trunc(dbms_random.value(232,249)) into num1 from dual;
     select TRUNC(SYSDATE + 1) + (7*60+30)/(24*60) into time1 from dual;
     select TRUNC(SYSDATE + 1) + (20*60+30)/(24*60) into time2 from dual;
       insert into checkinout values(1,time1,'I',0,num,'自增id','机器id');
        insert into checkinout values(1,time2,'I',0,num1,'自增id','机器id');
   end;
 --测试存储过程  
call  pro_time();
 
 --定时于每天早上七点半运行一次
  declare job2010 number;
  begin 
 dbms_job.submit(job2010,'pro_time();',sysdate,'TRUNC(SYSDATE + 1) + (7*60+30)/(24*60)');
  end;
 --查询插入的数据
select * from checkinout;
原创粉丝点击