select count(*) into  icount  from ecc_imr_term aa where aa.distributer_id in 
( select distributer_id  from ecc_distributer where node_id='20') group by aa.distributer_id本来ICOUNT只有一个值可以用以上语句,现在COUNT(*)的值有多个,我要判断这个值,要怎么来判断呢?要用循环还是游标来获取这一组COUNT(×),最后来判断!

解决方案 »

  1.   

    group by aa.distributer_id 有了这个并且你aa.distributer_id有多个不同值的话,肯定会出来多个结果
    用游标循环吧
      

  2.   

    用游标循环
    create or replace function SF_OPS_GETSIBOXNO(op_id in varchar2,sf_type in varchar2)
    return varchar as
    boxno varchar2(300);/*传入参数:1.业务编号 2.类型(a.未排车 WPCY,b.已派未送 YPWS,c.全部未送 QBWS,d.全部信息 QBXX)
    返回参数:箱型*箱量/箱号*/cursor box1 is
          select box_no from ops_seai_asn_det where operation_id=op_id and Assign_date is null ;
    begin
    boxno:='';
    if sf_type = 'WPCY' then
       for a1 in box1 loop
          if boxno is null then
             boxno := a1.box_no;
          else
             boxno := boxno||','||a1.box_no;
          end if;
        end loop;
    return boxno;
    end SF_OPS_GETSIBOXNO;