create or replace function id_is_good(empid in number) return boolean
as
       v_id number;
begin
       select count(*) into v_id from scott.emp e where e.empno=empid;        
  return 1=v_id;
exception
  when others then
       return false;
end id_is_good;----------------------------------------------------------------------SQL> select system.id_is_good(7369) from dual;
 
select system.id_is_good(7369) from dual
 
ORA-06552: PL/SQL: Statement ignored
ORA-06553: PLS-382: 表达式类型错误

解决方案 »

  1.   

    回LS,这代表如果v_id存在就返回turn值,这个function我能编译过,但执行时就报错啦,不知为何
      

  2.   

    类型问题
    这个函数返回的是boolean型
    布尔型在pl/sql中能正常使用,但在sql中不行
      

  3.   

    把return 1=v_id;
    改为if nvl(v_id,0)>0 then
        return true;
      else
        return false;
      end if;
    即使这样改了,你的select system.id_is_good(7369) from dual;也会报错
    因为表boolean不可能从select语句中返回
      

  4.   

    将返回值改成0,1就ok了 别用true和false
      

  5.   


    返回的是0或者1,不是true以及false