oracle - Trigger Cannot query on same table? -
i want create trigger before insert or update trigger on table customer:
create table customer (custnum number, debitnum number );
the validation need in trigger customer not assigned same debitnum twice.
so trigger code is:
create or replace trigger xx_mytrig before insert or update on customer declare ln_count number; begin select count(custnum) ln_count customer custnum:=:new.custnum , debitnum:=new.debitnum; if ln_count>0 raise fnd_api.g_exc_error; end if; end;
when insert or update noticed select statement not executed. how can query on same table...?
i think can achieve adding unique constraint on columns custnum , debitnum. approach more effective implemented trigger.
alter table customer add constraint constraint_name unique (custnum , debitnum);
Comments
Post a Comment