if c_Line.cat1 <> null then
      begin
        select category_id
          into x_category_id
          from mtl_categories_v a
         where a.category_id = c_Line.cat1;      
      exception
        when NO_DATA_FOUND then
          x_Message := '物料类集无效!';
      end;      
    end if;       
    if c_Line.cat2 <> null then
      begin
        select category_id
          into x_category_id
          from mtl_categories_v a
         where a.category_id = c_Line.cat2;      
      exception
        when NO_DATA_FOUND then
          x_Message := '物料类集无效!';
      end;       
    end if;       
    if c_Line.cat3 <> null then
      begin
        select category_id
          into x_category_id
          from mtl_categories_v a
         where a.category_id = c_Line.cat3;      
      exception
        when NO_DATA_FOUND then
          x_Message := '物料类集无效!';
      end;       
    end if;       
    if c_Line.cat4 <> null then
      begin
        select category_id
          into x_category_id
          from mtl_categories_v a
         where a.category_id = c_Line.cat4;      
      exception
        when NO_DATA_FOUND then
          x_Message := '物料类集无效!';
      end;       
    end if;       
    if c_Line.cat5 <> null then
      begin
        select category_id
          into x_category_id
          from mtl_categories_v a
         where a.category_id = c_Line.cat5;      
      exception
        when NO_DATA_FOUND then
          x_Message := '物料类集无效!';
      end;       
    end if;       
    if c_Line.cat6 <> null then
      begin
        select category_id
          into x_category_id
          from mtl_categories_v a
         where a.category_id = c_Line.cat6;      
      exception
        when NO_DATA_FOUND then
          x_Message := '物料类集无效!';
      end;      
    end if;       
    if c_Line.cat7 <> null then
      begin
        select category_id
          into x_category_id
          from mtl_categories_v a
         where a.category_id = c_Line.cat7;      
      exception
        when NO_DATA_FOUND then
          x_Message := '物料类集无效!';
      end;       
    end if;       
    if c_Line.cat8 <> null then
      begin
        select category_id
          into x_category_id
          from mtl_categories_v a
         where a.category_id = c_Line.cat8;      
      exception
        when NO_DATA_FOUND then
          x_Message := '物料类集无效!';
      end;       
    end if;       
    if c_Line.cat9 <> null then
      begin
        select category_id
          into x_category_id
          from mtl_categories_v a
         where a.category_id = c_Line.cat9;      
      exception
        when NO_DATA_FOUND then
          x_Message := '物料类集无效!';
      end;       
    end if;       
    if c_Line.cat10 <> null then
      begin
        select category_id
          into x_category_id
          from mtl_categories_v a
         where a.category_id = c_Line.cat10;      
      exception
        when NO_DATA_FOUND then
          x_Message := '物料类集无效!';
      end;   
    end if;这个用循环该怎么写?
for i in 1 .. 10 loop    
     
end loop;

解决方案 »

  1.   

    楼主没说清楚
    c_Line.cat1是输入参数?
    总共有10个输入参数?
      

  2.   


      Cursor Item_Line Is
        Select aa. *
          From cmp_user.CPC_Mtl_System_Items_Interface aa
         Where aa.Batch_Id = p_id; For c_Line In Item_Line Loop
      

  3.   

    for i in 1 .. 10 loop    
         
        if c_Line.cat% i <> null then
          begin
            select category_id
              into x_category_id
              from mtl_categories_v a
             where a.category_id = c_Line.cat% i;      
          exception
            when NO_DATA_FOUND then
              x_Message := '物料类集无效!';
          end;   
        end if;
    end loop;---------->字符联接的语法你查查。
      

  4.   

    null 应该用is not null吧