select 1 into num from Tablename where columnname='一个变量' rownum < 2;
if num >1 then 
  message(-20001,'已经存在');
end if;

解决方案 »

  1.   

    select column1 into number from tablename where c_olumn2=".....";
    错误提示我缺少表达式
      

  2.   

    create or replace function tablename(chr varchar2) return varchar2
    is
    num number;
    begin
    select 1 into num from v1 where v=chr and rownum < 2;
    if num > 0 then
    return '-20001,已经存在';
    end if;
    end ;
    /
      

  3.   

    create or replace function test(chr varchar2) return varchar2
    is
    num number;
    begin
    select 1 into num from tablename where column2=chr and rownum < 2;
    if num > 0 then
    return '-20001,已经存在';
    end if;
    end ;
    /select test(变量) from dual;
      

  4.   

    还有一个小疑问,就是在package bodies里面如何调用function中的函数呢?马上结..
      

  5.   

    bodyname.functionname 就可以了
      

  6.   

    但我的function在外面的function的目录中,引用的时候是在package bodies的目录中的呀,那又应该如何引用呢?
      

  7.   

    加好后直接引用functionname(STR)就可以了啊!