declare
 v_cnt int;
begin
  execute immediate 'select tt from duald WHERE col='''A'''' into v_cnt;
end;
当语句没值的时候,我需要V_CNT=0。。怎么处理。不需要抓错误。。如果抓了错误。
下面的代码以V_CNT=0想继续跑.怎么处理!

解决方案 »

  1.   

    execute immediate 'select nvl(tt,0) from duald WHERE col='''A'''' into v_cnt;
      

  2.   


    declare
     v_cnt int;
    begin
      begin
       execute immediate 'select tt from duald WHERE col='''A'''' into v_cnt;
      exception
        when no_data_found then
          v_cnt := 0;
      end;
    end; 
      

  3.   

    declare
     v_cnt int;
    begin
      begin
       execute immediate 'select tt from duald WHERE col='''A'''' into v_cnt;   execute immediate 'select tt from duald WHERE col='''B'''' into v_cnt;
      exception
        when no_data_found then
          v_cnt := 0;
      end;
    end; 如果B的条件需要v_cnt:=1?怎么办??
      

  4.   


    declare
     v_cnt int;
    begin
      begin
       execute immediate 'select tt from duald WHERE col='''A'''' into v_cnt;
      exception
        when no_data_found then
          v_cnt := 0;
      end;
      
      begin
       execute immediate 'select tt from duald WHERE col='''B'''' into v_cnt;
      exception
        when no_data_found then
          v_cnt := 1;
      end;
    end; 
      

  5.   

    v_cnt int;
    添加默认值即可
    v_cnt int:=0;
      

  6.   


    但提示ORA-01403: 未找到数据
    ORA-06512: 在 "SYS.EVSYS_LIST", line 142
    ORA-06512: 在 line 2
      

  7.   


    在同一个PROC怎么处理呢。。  
      

  8.   

    再定义一个变量,然后select count(*) into 变量 from duald WHERE col='''A''''
    然后通过变量if判断v_cnt的值