create or replace procedure yqw1 is 
type 
   array_type IS table of number INDEX BY BINARY_INTEGER;
   city  array_type;   
   
 --  array_zhang IS table of number INDEX BY BINARY_INTEGER;
   isscount array_type;
   reccount array_type;
   issamount array_type;
   recamount array_type;
begin
  city(1):=1111;
  city(2):=1111;
  city(3):=1111;
  for i in 1..3 loop
  isscount(i):=0;
  reccount(i):=0;
  issamount(i):=0;
  recamount(i):=0;
end loop;
 for j in 1..3 loop
      select LTRIM(RTRIM(count)),LTRIM(RTRIM(amount)) into isscount(j),issamount(j) from temp1 where opccode=city(j) and rpccode='1000';
      select LTRIM(RTRIM(count)),LTRIM(RTRIM(amount)) into reccount(j),recamount(j) from temp1 where opccode='1000' and rpccode=city(j);
      EXCEPTION 
       when NO_DATA_FOUND THEN
       NULL;
 end loop;
end yqw1;系统报什么 exception......错误

解决方案 »

  1.   

    select LTRIM(RTRIM(count)),LTRIM(RTRIM(amount)) into isscount(j),issamount(j) from temp1 where opccode=city(j) and rpccode='1000';
    你这个如果返回结果多与一条,就会报exception
    改为试试
    select LTRIM(RTRIM(count)),LTRIM(RTRIM(amount)) into isscount(j),issamount(j) from temp1 where opccode=city(j) and rpccode='1000' and rownum=1;
      

  2.   

    ...
    for j in 1..3 loop
    begin
        select LTRIM(RTRIM(count)),LTRIM(RTRIM(amount)) into isscount(j),issamount(j)  from temp1 where opccode=city(j) and rpccode='1000';
          select LTRIM(RTRIM(count)),LTRIM(RTRIM(amount)) into reccount(j),recamount(j) from temp1 where opccode='1000' and rpccode=city(j);
          EXCEPTION 
           when NO_DATA_FOUND THEN
           NULL;
    end;
     end loop;
    ...
      

  3.   

    多谢bzszp(SongZip)和cenlmmx(学海无涯苦作舟),我的意思就是想如果一个select没有结果,还能继续查询,不要整个模块退出。所以bzszp(SongZip)30给分,cenlmmx(学海无涯苦作舟)给20分