【发布时间】:2020-09-22 07:00:01
【问题描述】:
创建一个从员工表中删除行的过程。它应该接受1个参数,部门名称;只删除属于该部门的员工记录。显示删除了多少员工,否则引发“DeptNotFoundException”并打印消息“未找到记录”。
Employee:
column name datatype constraints
EMP_ID NUMBER(5) PK
EMP_NMAE VARCHAR2(25) NOT NULL
SALARY NUMBER(10,2)
DEPT VARCHAR2(25)
EMP_ID EMP_NAME SALARY DEPT
101 JOHN 54000 MECH
102 TOM 43000 CSE
103 WILLIAM 34560 MECH
104 STEVE 56000 CSE
105 SMITH 23450 IT
我的代码是,
set serveroutput on;
create or replace procedure delete_EMPLOYEE(dept_name in EMPLOYEE.dept%type) is
deptnotfound EXCEPTION;
begin
delete from EMPLOYEE where dept=dept_name;
if (sql%found) then
dbms_output.put_line(sql%rowcount || 'Employee record(s) got deleted.');
else
raise DeptNoFound;
end if;
EXCEPTION
when DeptNoFound then
dbms_output.put_line('No Records Found.');
end delete_EMPLOYEE;
/
它编译成功但不是测试用例。只通过了 1 个测试用例,而不是 2 个。谁能帮帮我,拜托....
【问题讨论】:
-
什么“测试用例”?程序看起来不错并且工作正常。如果您发布您的测试方式会有所帮助。
-
@要分享失败的测试用例场景吗?