create or replace function F_name 
(n1 table.bb%type
)
  return Integer  as 
  n1 table.bb%type;
begin
SELECT bb into n1 FROM TABLE
WHERE AA=1
AND BB=n1
AND CC=3 
 commit;
 EXCEPTION
     when  others then 
       RAISE_APPLICATION_ERROR(-20000, '录入了非法数据!保存失败!
                                        请核对后重新录入...');
end;

解决方案 »

  1.   

    写动态SQL, 用本地动态sql的方法执行
    GOOD LUCKY!
      

  2.   

    create procedure pro(p_bb in number)
    as
    num number;
    begin
    select count(1) into num from tabname where aa=1 and nvl2(p_bb,bb,1)=nvl(p_bb,1) and cc=3;
    end;
    /
      

  3.   

    存在什么条件时才加入b=2啊,我默认当b=2时执行select * from table where a=1 and b=2 and c=3;
    create or replace pro(num in number)
    is
    va table%rowtype;
    vb table.b%type;
    bgein
    if vb=2 then
     select * into va from table where a=1 and b=2 and c=3;
    else 
    select * into va from table where a=1 and c=3;
    end if;
    dbms_output.put_line(table.col1||table.col2||.......||table.coln);
    end pro;
    不知道这样行吗?
      

  4.   

    select * from tablename t 
    where aa = 1
    and nvl((select column_name from dba_col_comments where column_name = 'BB' and table_name = 'TABLENAME'),1) = nvl((select 2 from dba_col_comments where column_name = 'BB' and table_name = 'TABLENAME'),1) 
    and CC=3
    试试这个应该没有问题
      

  5.   

    需要将上面的语句改成动态的SQL,才行
      

  6.   

    select * from tablename
    where aa = 1
    and nvl((select column_name from dba_tab_columns 
                    where column_name = 'BB' and table_name = 'TABLENAME'),1) 
      = nvl((select 2 from dba_tab_columns
                    where column_name = 'BB' and table_name = 'TABLENAME'),1)
    and cc = 3