输入参数:
ia,ib;
输出参数:cp
select c into cp from tabletest where a=ia and b=ib
如果ia='' 那么a=ia这个条件不要请教各位高手怎么写?

解决方案 »

  1.   

    CREATE OR REPLACE PROCEDURE getdata_from_tabletest 
    (
        in_ia        IN  NUMBER,
        in_ib        IN  NUMBER,
        out_cp       OUT NUMBER
    )
    is
        vs_sql  varchar2(50);
    begin
        vs_sql  := 'select c from tabletest where b=' || to_char(in_ib);    if (in_ia is not null) then
            vs_sql  := vs_sql || ' and a=' || to_char(in_ia);
        end if;    EXECUTE IMMEDIATE vs_sql into out_cp;
        commit;
        
        EXCEPTION WHEN others THEN null;
    end;
      

  2.   

    IF ia is not null then 
    select c into cp from tabletest where a=ia and b=ib;
    else
    select c into cp from tabletest where b=ib;
    End if;
      

  3.   

    select c into cp from tabletest where a=NVL(ia,A) and b=ib
      

  4.   

    qiaozhiwei(乔) :
    这样写不错,高!