please correct this trigger [message #396894] |
Wed, 08 April 2009 06:00  |
sekharsomu
Messages: 72 Registered: December 2008
|
Member |
|
|
Create or replace trigger ranger
before insert on emp
for each row
begin
if new.empno>5000
then
raise_application_error(-20400,'greater than expected');
end if;
end;
/
error
asking for declaration of new.empno
|
|
|
|
|
|
|
|
|
|
|
|
|
Re: please correct this trigger [message #396991 is a reply to message #396986] |
Wed, 08 April 2009 10:12   |
ThomasG
Messages: 3212 Registered: April 2005 Location: Heilbronn, Germany
|
Senior Member |
|
|
user2004 wrote on Wed, 08 April 2009 17:01 | Instead of creating trigger its better to have check contraint on the table. Am I correct?
|
In this exact case yes.
Otherwise it would depend on the check. If the check that has to be done is somewhat "dynamic", then a check constraint can't be used.
For example you could use a trigger to prevent inserts of dates greater than sysdate and smaller than sysdate - 20 in a transaction table, which can't be done with a check constraint because sysdate is not deterministic.
|
|
|
|