想执行下面的操作
select * from table A where s_time=:currentTime;
我现在使用plsql,直接在sql window 下面调用,把:currentTime直接换成实际的时间,执行很快,1秒之内完成,
把上面的东西写成procedure,把查询语句放到游标里,执行起来非常慢,大概30秒。有什么其他办法完成上面的操作吗?我希望每查询一次,更新:currentTime,需要循环。

解决方案 »

  1.   

    看了一下,好像参数传递有问题,使用sql直接查询有结果,调用procedure没有结果,我要做的查询是
    select * from tableA where ss_time=to_date('25-12-2009 14:00:00', 'dd-mm-yyyy hh24:mi:ss');在procedure中定义如下
    create or replace procedure inNon2(dateTo date) as
    temp tableA %rowtype;
    temp2 tableA %rowtype;
    end_con number;cursor selectData(s_time in date) is
    /*select * from section_status_detect_5 where status_time=s_time and section_index='4035NS';*/
    select * from tableA where status_time=s_time;
    begin
    end_con:=1;
      open selectData(dateTo);
      loop
      fetch selectData into temp;
      dbms_output.put_line(to_char(temp.volume));
      /*exit when selectData%notfound; */
      exit when end_con>=5;
      end_con:=end_con+1;
      dbms_output.put_line(to_char(end_con));
      end loop;
      close selectData;
    end ;在test window 中执行如下declare datetopredict date;
    begin
      datetopredict:=to_date('25-12-2009 14:00:00', 'dd-mm-yyyy hh24:mi:ss');
      -- Call the procedure
      innon2(:datetopredict);
    end;
      

  2.   

    declare datetopredict date;
    begin
      datetopredict:=to_date('25-12-2009 14:00:00', 'dd-mm-yyyy hh24:mi:ss');
      -- Call the procedure
      innon2(datetopredict);--innon2(:datetopredict);不要:
    end;
      

  3.   

    发现是我自己传递参数的问题,直接右键我的procedure->test,会出现下面的内容
    begin
      -- Call the procedure
      innon2(datetopredict => :datetopredict);
    end;
    需要改成
    begin
      -- Call the procedure
      innon2(:datetopredict => datetopredict);
    end;
    默认的方式传递好想也反了,不知道为什么,还是谢谢