日期:2014-05-17  浏览次数:20921 次

函数调用错误:wrong number or types of arguments in call to 'ID_IS_GOOD'
函数:
SQL code
CREATE OR REPLACE FUNCTION id_is_good
  (i_student_id IN NUMBER)
  RETURN BOOLEAN
AS
  v_id_cnt NUMBER;
BEGIN
  SELECT COUNT(*)
    INTO v_id_cnt
    FROM student
   WHERE student_id = i_student_id;
  RETURN 1 = v_id_cnt;
EXCEPTION
  WHEN OTHERS
  THEN
    RETURN FALSE;
END id_is_good;


调用:
SQL code

 1 declare
 2    v_local_first_name student.first_name%type;
 3    v_local_last_name student.last_name%type;
 4    rst BOOLEAN ;
 5  begin
 6    rst := id_is_good(&sv,v_local_first_name, v_local_last_name);
 7    dbms_output.put_line(rst);
 8  end;




运行的时候在pl/sql developer,我输入一个数字,但报错:
ORA-06550: line 6, column 10:
PLS-00306: wrong number or types of arguments in call to 'ID_IS_GOOD'
ORA-06550: line 6, column 3:
PL/SQL: Statement ignored
ORA-06550: line 7, column 3:
PLS-00306: wrong number or types of arguments in call to 'PUT_LINE'
ORA-06550: line 7, column 3:
PL/SQL: Statement ignored

我实在是看不出来哪错了,plsql就是这样,提示得总是啰哩啰嗦,还没说到点上。就像它的文档写得一样烂。


------解决方案--------------------
1、调用时参数个数太多。
2、dbms_output.put_line函数不能打印blooean类型的值。
SQL code
--如果需要打印,可以这样
if rst then
  dbms_output.put_line('TRUE');
else
  dbms_output.put_line('FALSE');
end if;