【发布时间】:2013-11-23 07:59:47
【问题描述】:
我正在 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;
【问题讨论】:
-
您何时收到此消息?触发器何时触发?更重要的是,您是否在网络上进行过任何研究?只需使用谷歌搜索
ORA-01403即可返回许多有用的信息。 -
是的,我做了谷歌但仍然没有得到想要的结果。在插入表之前触发触发。当有人在表中输入新条目时
标签: database oracle triggers ora-01403