create or replace procedure proc_getcursor_value(Fyear IN CHAR,
                                                 Fmonth IN CHAR)
is     v_orgid       ia_ia_bill_line.org_id%TYPE;
     v_stockorgid ia_ia_bill_head.stock_org_id%TYPE;
     v_styleid     ia_ia_bill_line.style_id%TYPE;
     v_ornacode    ia_ia_bill_line.orna_code%TYPE;
     v_num          ia_ia_bill_line.num%TYPE;
     i             number:=1;
         cursor term_type is
         SELECT h.org_id, h.stock_org_id, l.style_id, l.orna_code, l.num 
           FROM ia_ia_bill_head h, ia_ia_bill_line l
            where h.id=l.head_id
             and h.fiscal_year=Fyear
             and h.fiscal_month=Fmonth
             and h.transceiver_flag<>1;
begin
  Open term_type;
  loop
   fetch term_type into v_orgid,v_stockorgid,v_styleid,v_ornacode,v_num;
   i :=i+1;
   if term_type%notfound
      then
           dbms_output.put_line('个数'||i);
           exit;
   end if;
   end loop;
 close term_type;
end proc_getcursor_value;
上面那个游标的select语句大概有9W多条语句,为什么打印的时候,i只为2?

解决方案 »

  1.   

    我感觉你什么都没有查询出来。
            SELECT h.org_id, h.stock_org_id, l.style_id, l.orna_code, l.num 
               FROM ia_ia_bill_head h, ia_ia_bill_line l
                where h.id=l.head_id
                 and h.fiscal_year=Fyear
                 and h.fiscal_month=Fmonth
                 and h.transceiver_flag<>1;
    关注一下Fyear、Fmonth条件是否满足。
    建议你把sql语句打印出来试一下。
      

  2.   

    首先你把你的游标加上过程的输入值,放到sql里执行,看能查出多少来
    游标最后一般定位到最后一行符合条件的记录上,
    按你打印的数据为2,应该是没有查出数据来。
     i             number:=1;
    一般赋值为0