【发布时间】:2019-08-10 13:56:45
【问题描述】:
我正在尝试构建一个触发器来检查要插入的行是否存在于另一个表中。
基本上我的 2 个表共享一列 ID。 当新行在另一个表中至少不存在一次时,我想阻止插入。
我有这个:
create or replace trigger BIM
before insert on TABLE1
for each row
begin
if not exists (select 1 from TABLE2 where TABLE2.ID = :new.TABLE1.ID)
then
raise_application_error(-20634, 'Error');
end if;
end;
但我明白了:
PLS-00049: bad bind variable 'NEW.TABLE1'
【问题讨论】:
标签: sql oracle oracle11g triggers database-trigger