大家好,小弟刚接触存储过程和Oracle的job。写了个存储过程,并把它设为定时任务,每天的凌晨一点执行。。存储过程,手动执行没有问题。但是,定时任务执行时,就执行一次,next date 自动变为 “4000-1-1”,broken掉了。。
    大家帮我看看哪里出了问题??急!急!急! 在线等。下面是我的存储过程和定时任务:存储过程:
create or replace procedure update_merinfo_fee_rate is
       Cursor cusor_1 is select * from pmmerinfo ; --取得商户表的游标,目的是遍历取得 商户号 和 费率
       fee_rate float := 1.5; --定义费率变量,并赋初值
begin
  open cusor_1;----打开游标
  for cur_result in cusor_1 LOOP--遍历游标
      begin--取得一个商户的费率,并修改订单信息表中的 手续费
           fee_rate := to_number(cur_result.transfeerate);
           
           update ofordertradea ab set ab.transfee = (ab.transamt*fee_rate) where ab.merchantid = cur_result.merchantid and ab.transtime >= to_char((sysdate-1) , 'yyyymmdd') and ab.transtime < to_char((sysdate) , 'yyyymmdd');
      end; 
      
  end LOOP;--遍历游标结束
  close cusor_1; --关闭游标
  
end update_merinfo_fee_rate;--存储过程结束定时任务:
begin
  sys.dbms_job.submit(job => :job,
                      what => 'update_merinfo_fee_rate;',
                      next_date => to_date('10-06-2010 01:00:00', 'dd-mm-yyyy hh24:mi:ss'),
                      interval => 'trunc(sysdate)+1+1/24');
  commit;
end;
/谢谢!

解决方案 »

  1.   

    http://topic.csdn.net/t/20061009/09/5068540.html
      

  2.   

    不是时间的问题。我debug的时候,程序一直在 “Cursor cusor_1 is ” 和 “open cusor_1;----打开游标” 之间运行,走到 open 的时候,就返回 来回三次就报异常说“游标已打开。。”
      

  3.   

    问题解决了,谢谢了兄弟
     for循环利用 游标时,自动执行游标的时候,open、fetch、close 语句 和 循环语句的功能;当进入循环时,游标for循环语句自动打开游标,并提取第一行游标数据,当程序处理完当前行而进入下一次循环时,游标for循环语句自动提取下一行数据。当处理完所有的数据时,结束循环,并自动关闭游标。