which will fire first ? Trigger or Constraint
Answer Posted / lakkireddy ashok
Always trigger will fire first
eg:create table T_CHK (a number check (A < 99));
INSERT INTO T_CHK VALUES(101);
ORA-02290: check constraint (APPS.SYS_C00207769) violated
if u create trigger
CREATE TRIGGER CHKT BEFORE INSERT ON T_CHK
FOR EACH ROW
BEGIN
IF :NEW.A >100 THEN
RAISE_APPLICATION_ERROR(-20011,'VALUES SHOULD BE < 100');
END IF;
END;
INSERT INTO T_CHK VALUES(101);
ORA-20011: VALUES SHOULD BE < 100
ORA-06512: at "APPS.CHKT", line 3
ORA-04088: error during execution of trigger 'APPS.CHKT'
if u don't create trigger then constraint will be first otherwise if u create trigger to the same table with same DML operations here trigger will fire first instead of constraint firing
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
what is the difference between group by and order by in sql? : Sql dba
How long will it take to learn pl sql?
What is pl sql collection?
Is big data nosql?
How do I partition in sql?
What is lookup table in sql?
What is the difference between delete and truncate statement in sql?
How do you run a query?
what are the drivers in mysql? : Sql dba
Can instead of triggers be used to fire once for each statement on a view?
How to Declare Fixed Length String Value In PL SQL
What does (+) mean in sql joins?
Are null values same as that of zero or a blank space?
what is data control language? : Sql dba
What are the types of join in sql?