【发布时间】:2010-04-18 06:57:51
【问题描述】:
在我的代码中,我输入了雇员表中不可用的薪水,然后再次在异常块中的雇员表的主键列中插入重复的雇员 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;
【问题讨论】:
-
从技术上讲,您的原始异常没有得到处理,它引发了另一个异常。在我看来,这似乎是预期的行为。
标签: sql oracle plsql ora-01400 ora-01403