我每天都要更新前一天的的两条语句,更新提交后,再去执行那天的存储过程prc_pnr和prc_fdl,每天都手动,太麻烦了,所以想写个过程。我写的过程如下,但不确定时间有没有写对
create or replace procedure CTU_JHG_PRICE 
begin
update p2002_pnr t  
set qu_jian='40',line_price=510
where flight_date = to_char(sysdate-1,'yyyymmdd')
and comp='EU'
and dep='CTU'
and arr='JHG'
and is_goshow=0
and is_noshow=0
and cabin='X'
commit;
update p2002_pnr  
set qu_jian='40',line_price=510
where flight_date = to_char(sysdate-1,'yyyymmdd')
and comp='EU'
and dep='JHG'
and arr='CTU'
and is_goshow=0
and is_noshow=0
and cabin='X'
commit;
PRC_PNR(sysdate-1);
commit;
PRC_FDL(sysdate-1);
end CTU_JHG_PRICE;

解决方案 »

  1.   

    sysdate-1
    是表示从当前时间算起,前24小时,也就是前一天。
      

  2.   

    1、flight_date字段是否为YYYYMMDD格式?
    2、2个存储过程的输入参数是否精确到sysdate?
    以上若确定,就没问题。
      

  3.   

    我知道,我的意思也就是要达到那个效果,这么跟你说吧,我每天都要先执行上面那两个语句,然后提交后再执行下面的过程,我写了这个过程,这样可以包括前面我操作的步骤么,他每天会自动执行吗?还有就是我掉的时间这样写没错吧。要不要像上面那样用到to_char之类的。
      

  4.   

    表里的数据是2012-4-5,假如原来没写这个过程前,我是这样操作的。先update p2002_pnr t   
    set qu_jian='40',line_price=510
    where flight_date = to_char(sysdate-1,'yyyymmdd')
    and comp='EU'
    and dep='CTU'
    and arr='JHG'
    and is_goshow=0
    and is_noshow=0
    and cabin='X'
    提交后
    测试pnr和fdl过程时间改为2012-4-5,这样就把那天的改过来了
      

  5.   

    1、你要把存储过程放在job里它才会每天自动执行;
    2、调用的存储过程的输入参数是什么类型,你转换成相应类型就行。
      

  6.   

    过程中的这些commit必要吗?
    建议拿掉