关键是 它没有任何返回值
mysql := 'select max(a.num) from a,b where a.id = b.id';
execute immediate mysql into mynum;
if mynum is null then
  -- no data found
end if;
...

解决方案 »

  1.   

    谢谢楼上的,不过我要取的就是a.num, 比如a.id 在b中没有与之相应的b.id,那么 
    execute immediate mysql into mynum;时候就会出错,不知道是不是NULL不能into的吧
      

  2.   

    忘了说了,我是在游标中取的,是不是跟这个有关呢?
    for r_gsa in c_gsa loopmysql := 'select nvl(unpay_fee,0) ' || ' from acc_bill_' || TO_CHAR(r_gsa.city_id) || ' where  bill_month='||''''||to_char(add_months(SYSDATE,-1),'YYYYMM')||''''||' and acc_id='||r_gsa.acc_id ; --dbms_output.put_line(r_gsa.acc_id);


    execute immediate mysql INTO unpayfee;

    if unpayfee is NULL then
       unpayfee := 0;
    end if;end loop;
      

  3.   

    没有关系 把 nvl(unpay_fee,0) 改成 nvl(max(unpay_fee),0) 即可!