本帖最后由 soft_wz 于 2010-08-12 10:58:31 编辑

解决方案 »

  1.   

    1. where to_char( 回贴时间, 'yyyymm' ) = '201007'
    2.
    3. 用ref_cursor返回。
      

  2.   

    procedure proc_QryCert(i_id  in varchar2,        
                            o_Cur     out SYS_REFCURSOR)    
        as
    begin
     open o_Cur for
             select a
              from test t
             where t.a=i_id;
    end;
      

  3.   


    create or replace procedure pro_test(ht_time varchar2)
    is
     ht_id varchar(20);
     username varchar(200);
     ht_qty integer;
     ht_show varchar(2000); cursor cursor_a is select 发贴人,贴子ID from 表A;begin
      open cursor_a;
      loop
        fetch cursor_a into username,ht_id;
        exit when cursor_a%notfound;
        select count(id) into ht_qty from 表B where 主贴ID = ht_id and to_char(回帖时间,'YYYYMM') = ht_time;
        ht_show := '发贴人:'||username||',回贴数:'||ht_qty;
        dbms_output.put_line(ht_show);
      end loop;
      close cursor_a;
    end;
      

  4.   


    create or replace procedure pro_test(ht_time in varchar2,ref out sys_refcursor)
    is
     ht_id varchar(20);
     username varchar(200);
     ht_qty integer;
     ht_show varchar(2000); cursor cursor_a is select 发贴人,贴子ID from 表A;begin
      open cursor_a;
      loop
        fetch cursor_a into username,ht_id;
        exit when cursor_a%notfound;
        select count(id) into ht_qty from 表B where 主贴ID = ht_id and to_char(回帖时间,'YYYYMM') = ht_time;
        ht_show := '发贴人:'||username||',回贴数:'||ht_qty;
        dbms_output.put_line(ht_show);
      end loop;
      close cursor_a;
    end;
    在这里加个sys_refcursor。执行完后print。