函数:
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;调用: 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就是这样,提示得总是啰哩啰嗦,还没说到点上。就像它的文档写得一样烂。
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;调用: 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就是这样,提示得总是啰哩啰嗦,还没说到点上。就像它的文档写得一样烂。
2、dbms_output.put_line函数不能打印blooean类型的值。
--如果需要打印,可以这样
if rst then
dbms_output.put_line('TRUE');
else
dbms_output.put_line('FALSE');
end if;
昨天晚上贴错了,实际上给一个参数也是这样的。后来参考2楼的提示,发现put_line不能直接输入booelan型的,真是弱智啊。请问,转义字符怎么输出,我要在put_line中输出一个单引号,除了用chr函数,有无转义字符可用?
select 'It''s a pen' from dual;