create or replace procedure telnums(begintime date,endtime date) is
declare
 v_cou number := (begintime-endtime)/60*12*1000;
 v_i number:=0; 
 tel number;
 begin
 loop
 exit when v_i>=v_cou;
  select count(*) into tel from ay_agent_log where AY_BEGIN_TIME=begintime;
  v_i:=v_i+1;
  begintime:=begintime+5*60*1000;
  end loop;
  end;

解决方案 »

  1.   

    1.参数1在过程中有赋值,所有 应该给与 out.
    telnums(begintime out date,endtime date)2.检查一下SQL是否有效,表和字段是否存在。
     select count(*) into tel from ay_agent_log where AY_BEGIN_TIME=begintime;
      

  2.   

    我在sql窗口执行的,不知道哪里看错误提示哦
      

  3.   

    我都试过了。你排除一下是个是下面的问题
    1.参数1在过程中有赋值,所有 应该给与 out.
    telnums(begintime out date,endtime date)2.检查一下SQL是否有效,表和字段是否存在。
     select count(*) into tel from ay_agent_log where AY_BEGIN_TIME=begintime;
      

  4.   

    pl/sql中,procedure下找到你的过程,编译下,看下什么错误,贴出来sqlplus中执行后有错误,show error,看下错误
      

  5.   

    报错是这样的
    SQL> create or replace procedure telnums1(begintime date,endtime date) is
      2   v_cou number := (begintime-endtime)/60*12*1000;
      3   v_i number:=0;
      4   tel number;
      5   begin
      6   loop
      7   exit when v_i>=v_cou;
      8    select count(*) into tel from ay_agent_log where AY_BEGIN_TIME=begintime;
      9    v_i:=v_i+1;
     10    begintime:=begintime+5*60*1000;
     11    end loop;
     12    end;
     13  
     14  /
     
    Warning: Procedure created with compilation errors
     
    SQL> show error
    Errors for PROCEDURE IMSMON.TELNUMS1:
     
    LINE/COL ERROR
    -------- ------------------------------------------------------------------------
    8/33     PL/SQL: ORA-00942: table or view does not exist
    8/3      PL/SQL: SQL Statement ignored
    10/3     PLS-00363: expression 'BEGINTIME' cannot be used as an assignment target
    10/3     PL/SQL: Statement ignored
      

  6.   

    去掉 declare 之后提示什么错误?
      

  7.   

    create or replace procedure telnums1(begintime date,endtime date) 
    改成  create or replace procedure telnums1(begintime in out  date,endtime date) 就不会报错了
      

  8.   

    否则  pls-00363 表达式 begintime 不能作为赋值目标。
      

  9.   

    两个错误:ORA-00942,检查下表ay_agent_log与字段 AY_BEGIN_TIME是否确实存在
              PLS-00363,你的参数没有加in out修饰符,create or replace procedure telnums1(begintime date,endtime date)改成create or replace procedure telnums1(begintime in date,endtime in date)
      

  10.   

    create or replace procedure telnums(begintime IN date,endtime IN date)
    as
     v_cou number := (begintime-endtime)/60*12*1000;
     v_i number:=0;
     tel number;
     tmp_time DATE;BEGIN
       tmp_time := begintime;
     loop
     exit when v_i>=v_cou;
      select count(*) into tel from ay_agent_log where AY_BEGIN_TIME=begintime;
      v_i:=v_i+1;
      --begintime:=begintime+5*60*1000;  tmp_time:=tmp_time+5*60*1000;  end loop;
    end;
      

  11.   

    你好,应该快好了,现在报这个错 我没有看懂哦
    pls-00103:encountered the symbol "=" when expecting one of the follow:.;when
    pls-00103:encountered the symbol "end"
      

  12.   

    [Quote=引用 16 楼 yixilan 的回复:]
    create or replace procedure telnums(begintime IN date,endtime IN date)
    as
     v_cou number := (begintime-endtime)/60*12*1000;
     v_i number:=0;
     tel number;
    tmp_time DATE;BEGIN
      tmp_time := begintim……
    [/Quote
    已经好了 谢谢你哦