在我的代码中,我输入了员工表中不可用的薪水,然后再次在异常块中的员工表的主键列中插入重复的employee_id,我正在处理未找到数据No data found
的异常,但我不知道为什么最后也会出现异常?
输出:
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
这是代码:
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;