No_data_found exception is propagating to outer block also?

Posted by Vineet on Stack Overflow See other posts from Stack Overflow or by Vineet
Published on 2010-04-18T06:57:51Z Indexed on 2010/04/18 9:03 UTC
Read the original article Hit count: 412

Filed under:
|
|
|
|

In my code i am entering the salary which is not available in employees table and then again inserting duplicate employee_id in primary key column of employee table in exception block where i am handling no data found exception but i do not why No data found exception in the end also?

OUTPUT coming:

Enter some other sal
ORA-01400: cannot insert NULL into ("SCOTT"."EMPLOYEES"."LAST_NAME")
ORA-01403: no data found  --This should not come according to logic

This is the code:

DECLARE
v_sal number:=&p_sal;
v_num number;
BEGIN
   BEGIN
            select salary INTO v_num from employees where salary=v_sal;
   EXCEPTION
           WHEN no_data_found THEN
                   DBMS_OUTPUT.PUT_LINE('Enter some other sal');

           INSERT INTO employees (employee_id)values(100) ;
   END;
EXCEPTION
   WHEN OTHERS THEN
   DBMS_OUTPUT.PUT_LINE(sqlerrm);
END;       

© Stack Overflow or respective owner

Related posts about Oracle

Related posts about exception