定时生成数据

create or replace procedure pro_nor_maktask
is
taskid number;
sepr varchar2(1);
sbuf varchar2(200);
sres varchar2(200);
pos number := 1;
istart number;
r_task varchar2(100);

rs_row tb_nor_tactic%rowtype;
--查询是策略性质为==自动
cursor my_cursor is
select ta.* from tb_nor_tactic ta where ta.nature=1;
begin
--打开游标
open my_cursor;
loop
fetch my_cursor into rs_row;--通过游标提取行记录
--exit when my_cursor%notfound;--当找不到记录时退出循环
if my_cursor%notfound then
exit;
end if;
---表示下次运行的时间是当前时间
if(to_char(rs_row.nextdate,'yyyy-mm-dd') = to_char(sysdate,'yyyy-mm-dd')) then
---获取任务的当前id
select seq_nor_task.nextval into r_task from dual;
---新增到任务中
insert into tb_nor_task
(id, sortid, title, content, allsign, backsign, evalsign, startdate, enddate, estaber, estabtime, pubsign, pubuser, pubtime, finsign)
values
(r_task, rs_row.sortid, rs_row.title, rs_row.content, rs_row.allsign, rs_row.backsign, rs_row.evalsign, rs_row.startdate, rs_row.enddate, rs_row.estaber, rs_row.estabtime, rs_row.pubsign, rs_row.pubuser, rs_row.pubtime, 0);

if((rs_row.allsign = 1) and length(rs_row.userids)>0) then
dbms_output.put_line('start.....................................');
dbms_output.put_line('all userids is .....................................');
---在前面加一个','
sbuf := ','||rs_row.userids;
dbms_output.put_line(sbuf);
sepr := ',';
--istart := 1;
--tokenizer(istart, sepr, sbuf, sres, pos);
--if (pos <> 0) then
--dbms_output.put_line (sres);
--end if;
while (pos <> 0)
loop
istart := pos;
pro_splitstr(istart, sepr, sbuf, sres, pos);
----新增操作
insert into tb_nor_process
(id, userid, taskid, tasksign,prosign,fatherid)
values
(seq_nor_process.nextval,sres, r_task, 0,0,0);
dbms_output.put_line(sres||'::');
end loop;
end if;
end if;
-----修改策略下次执行时间
update tb_nor_tactic set nextdate = func_nor_cirnextdate(rs_row.cirnum,rs_row.cirunit) where id = rs_row.id;
end loop;
-- 关闭游标
close my_cursor;
end;
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值