oracle - PLSQL Function that doesn't raise exception properly -
i writing function return student's name when id entered. if id entered, doesn't exist in database, want exception raised. instead when enter incorrect student ids either returns nothing if have basic exception thrown or returns error message exception declared:
6503. 00000 - "pl/sql: function returned without value" *cause: call pl/sql function completed, no return statement executed. *action: rewrite pl/sql function, making sure returns value of proper type.
here's function:
create or replace function student( s_num in number) return varchar2 student_name varchar2(50); notexists exception; cursor s_cur select s_name roster s_num = s_id; begin open s_cur; fetch s_cur student_name; if s_cur%notfound raise notexists; end if; close s_cur; return student_name; exception when notexists -- handle error dbms_output.put_line('no student found.'); end;
any ideas?
when exception occurs, not returning actual error message.your function supposed return varchar. printing error , not returning actual error message.
exception when notexists -- handle error dbms_output.put_line('no student found.'); return 'no student found' end;
Comments
Post a Comment