which will fire first ? Trigger or Constraint
Answer Posted / pradeep
TRigger fires fist, it dose not matter is it befor or
after, please see the below trigger. Even i am not entering
not a valid DEPTNO, still trigger fires first and then
constraint error comes
CREATE OR REPLACE TRIGGER EMPTRIGGER after INSERT ON EMP
FOR EACH ROW
BEGIN
--- RAISE_APPLICATION_ERROR(-20201,'INVALID NUMBER');
dbms_output.put_line(
'in triggeerssssssssssssssssssssssssssssssssssssssssss');
END;
SQL> /
Trigger created.
SQL> INSERT INTO EMP(EMPNO,DEPTNO) VALUES(3333,50);
in triggeerssssssssssssssssssssssssssssssssssssssssss
INSERT INTO EMP(EMPNO,DEPTNO) VALUES(3333,50)
*
ERROR at line 1:
ORA-02291: integrity constraint (SCOTT.FK_DEPTNO) violated -
parent key not
found
| Is This Answer Correct ? | 0 Yes | 2 No |
Post New Answer View All Answers
Do we need commit after truncate?
How many joins can you have in sql?
what are rollup and cube in t-sql? : Transact sql
How is sql used in oracle?
Is sql microsoft?
What is view? Can we update view
Advantages and disadvantages of stored procedure?
What are secondary keys?
What is difference between primary and secondary key?
How many types of relationship are there?
What does data normalization mean?
Is sql a backend?
What is use of package in pl sql?
what is sql in mysql? : Sql dba
What are different types of queries in sql?