用if判断一下不就可以了吗,,
if ....
  open cursor1;
  ....
else
  open cursor 2;
  ....
end if ;

解决方案 »

  1.   

    我要这样的效果:
     procedure write_html(arr_name arr_line,a_product varchar2,model number)       
           is
              type cur   is ref cursor;
              c  cur;
              
           begin
               if model = 2 then
                  open c for 
                    select distinct qt.inventory_item_id,
                           sum(qt.ordered_quantity)ordered_quantity,qt.product_name
                          from   vv_om_qt_v qt
                           where qt.order_date >= nvl(begin_date,qt.order_date)
                           group by qt.inventory_item_id,qt.product_name;
               else if model = 1 then
                  open  c for
                      select distinct qt.inventory_item_id,
                           sum(qt.ordered_quantity)ordered_quantity,qt.product_name
                          from   vv_om_qt_v qt
                           where qt.order_date >= nvl(begin_date,qt.order_date)
                           
                           group by qt.inventory_item_id,qt.product_name;
               end if;
               end if;
               loop
               fetch c into r_qt;
                  exit when c%notfound; 
                   v_file := utl_file.fopen(location => v_dir,filename => v_filename,open_mode => 'A');                         
                   v_line := '<tr>';
                   v_line := v_line || '<td nowrap valign="middle" align="center"  style = "font-size=12px">'||nvl(r_qt.r_product,'&nbsp;')||'</td>';  
                   utl_file.put_line(v_file,v_line);
                   utl_file.fclose(v_file); 
                   v_file := utl_file.fopen(location => v_dir,filename => v_filename,open_mode => 'A');
               end loop;
               close c;
           end write_html;