oracle 存储过程指定某段时间随时更新表信息

---授权
GRANT SELECT ANY TABLE TO KMPRODUCT WITH ADMIN OPTION;

create or replace procedure p_insert_coupon is
couponGrantId coupon_grant.coupon_grant_id%TYPE;
couponId coupon_grant.coupon_id%TYPE;
couponIssuingId coupon_grant.coupon_issuing_id%TYPE;

loginId number(22);
day_num number(22);
v_index number(10);
startTime VARCHAR2(32);
endTime VARCHAR2(32);
--定义获取所有时代用户id的游标

cursor c_loginId is
select n_login_id from KMUSER.ERA_INFO;

begin
v_index := 0;
select EXTRACT(DAY FROM SYSDATE) into day_num from dual;
if day_num = 18 then
couponId := 12728;
couponIssuingId := 9909;
startTime := '2015-06-18 00:00:01';
endTime := '2015-06-19 00:00:01';
end if;
if day_num = 19 then
couponId := 12729;
couponIssuingId := 9910;
startTime := '2015-06-19 00:00:01';
endTime := '2015-06-20 00:00:01';
end if;
if day_num = 20 then
couponId := 12730;
couponIssuingId := 9911;
startTime := '2015-06-20 00:00:01';
endTime := '2015-06-21 00:00:01';

end if;
for v_loginId in c_loginId loop

for i in 1 .. 4 loop

INSERT INTO coupon_grant c
(coupon_grant_id,
coupon_id,
custom_id,
coupon_status,
grant_creattime,
grant_type,
starttime,
endtime,
coupon_issuing_id,
act_status,
grant_acttime)
VALUES
(seq_app_couponpgrant.nextval,
---规则id
couponId,
---会员id
v_loginId.n_Login_Id,
3,
sysdate,
11,
to_date(startTime, 'yyyy-mm-dd hh24:mi:ss'),
to_date(endTime, 'yyyy-mm-dd hh24:mi:ss'),
--发放设置7982
couponIssuingId,
1,
sysdate);

end loop;
v_index := v_index + 1;
if mod(v_index,5000)=0 then
commit;
end if;

end loop;
commit;
end p_insert_coupon;
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值