各行の後に INSERT トリガー イベントを持つ Oracle 10g トリガーがあり、挿入されている現在の行からトリガーのロジックを基にしたいと考えています。挿入されているユーザー テーブル フラグ列の値を取得し、トリガーで if-then-else を使用して、フラグが null の場合にのみ何かを実行したいと考えています。挿入される行のフラグ列の値を取得する方法についてのアイデアはありますか? 私の目標は、フラグ列の値が null の場合、以下のトリガーでロジックを実行しないことです。
Table: USERS
Columns:
id (PK generated from a DB sequence)
.... (more columns)
flag VARCHAR2(1 BYTE) and is nullable
引き金:
//goal is to not do any of the logic in the trigger below when flag is null
CREATE OR REPLACE TRIGGER "DBUSER"."TI_USERS"
AFTER INSERT
on Users
for each row
declare numrows INTEGER;
begin
select count(*) into numrows
from Customer
where
/* %JoinFKPK(:%New,Customer," = "," and") */
:new.Customer_Key = Customer.Customer_Key;
if (
/* %NotnullFK(:%New," is not null and") */
numrows = 0
)
then
raise_application_error(
-20002,
'Cannot INSERT Users because Customer does not exist.'
);
end if;
end;
ALTER TRIGGER "SIMPLEX"."TI_USERS" ENABLE