execute immediate 'select 1 from test  where id='||id||'  ' into chang; 
if  chang=1  then          --语句1
   else          --语句2  
         
   end if;
当chang的值为1时,过程可以执行。
当chang的值为NULL时,也就是那条SQL语句没有搜出记录。过程中的语句2就不执行了也没有报错。
这是怎么会事啊,应该怎么解决?
谢谢

解决方案 »

  1.   

    execute immediate 'select decode(count(*),0,null,1) from test  where id='||id||'  ' into chang; 
      

  2.   

    execute immediate 'select 1 from test  where id='||id||'  ' into chang; 
    if  (chang is not null) and (chang = 1)  then          --语句1
       else          --语句2  
             
       end if;
      

  3.   

    sbaz(万神渡劫) 的方法就可以解决了!xluzhong(Ralph) 的不行!为什么用我的方法不执行也不报错呢?怪事~~~