create or replace procedure aaa ( vi_num in integer,
                    vd_time1 in date, vd_time2 in date)
is 
 i integer ;
begin
 for i in 0..100 loop 
   select min(a),max(a) from record where number= vi_num and time
       between vd_time1 and vd_time2;
 end loop;
end;

解决方案 »

  1.   

    delare
    v_min record.a%type;
    v_max record.a%type;
    type t_user is varray(101) of number;
    v_user t_user:=t_user();
    begin
    for i in 1..100 loop
    select min(a),max(a) into v_min,v_max from record where number=i and time between time1 and time2;
    dbms_output.put_line(v_min||v_max);
    end loop;
    end;
    /以上要输入time1与time2两个值
      

  2.   

    volin,谢谢你的回复,首先这段代码写到sql*plus中不能执行,还有就是我要求循环执行完后,不是只查某个编号的最大、最小值,而是一组。
    beckhambobo,你给的代码我输入到sql*plus中提示 未知命令——其余行忽略这样的错误?
    能帮我分析一下为什么吗?谢谢!