我在 PL-SQL 中进行触发器以限制我的员工输入表单上部分/部门中的员工我得到 ORA-01403: no data found 。请任何人帮助我
create or replace trigger DEPT_STRENTH
after insert on empmasterinfo
for each row
DECLARE
-- local variables here
EMP_Count NUMBER;
MAX_Strength NUMBER;
V_Mainid VARCHAR2(100);
V_orgelementname VARCHAR2(100);
BEGIN
--taking value from form
V_Mainid := :new.mainid;
V_orgelementname := :new.orgelementname;
--Comparing values with existing
select d.strength
into MAX_Strength
from dept_strength d
-- Master table
where d.Mainid = V_Mainid
and d.orgelementname = V_orgelementname;
select count(e.employeeid)
into EMP_Count
-- Master table
from empmasterinfo e
where e.emp_status = 0
and e.Mainid = V_Mainid
and e.orgelementname = V_orgelementname;
if EMP_Count >= MAX_Strength then
RAISE_APPLICATION_ERROR(-20101,
'Maximum Number of Employees in Department Reached');
end if;
end DEPT_STRENTH;