PL/SQL Exception [message #310952] |
Wed, 02 April 2008 23:35  |
me_arindam
Messages: 26 Registered: March 2008 Location: India
|
Junior Member |
|
|
Hi,
I have a table employee.
I have the following code.
CREATE OR REPLACE package test_pck as
procedure test_p (n_id employee.pan_id%type);
end;
create or replace package body test_pck as
g_num number;
-------------------------------
function test_f(x employee.employee_id%type) return varchar2 is
b employee.emp_FIRST_NAME%type;
begin
dbms_output.put_line('inside test_f');
select emp_FIRST_NAME into b from employee where
employee_id = x;
dbms_output.put_line('the name is '||b);
return b;
exception
when others then
dbms_output.put_line('inside exception');
raise_application_error(-20999,employee_id is not there');
end;
------------------------------------------
procedure test_p (n_id employee.pan_id%type) is
a employee.employee_ID%type;
d varchar2(50);
begin
dbms_output.put_line('inside test_p');
select employee_id into a from employee where pan_id = n_id;
d:=test_f(a);
dbms_output.put_line('the emp_first_name is'||d);
exception
when others then
raise_application_error(-20998,'pan_id is not there');
end;
end test_pck;
When a is null(select employee_id into a from employee where pan_id = n_id) then it automatically oes into the exception.
But when b is null (select emp_FIRST_NAME into b from employee where employee_id = x;)it doesn't.
Could you please explain why it is happening.
Thanks,
Arindam
|
|
|
|
|
|
|
|