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
How do I add a database to sql?
What is a native sql query?
What are sql*plus environment variables?
what is the difference between myisam static and myisam dynamic? : Sql dba
Are views faster than queries?
Can we use views in stored procedure?
What are different functions in sql?
how to add a new column to an existing table in mysql? : Sql dba
What are dml commands?
How do I find duplicates in sql?
how many columns can be used for creating index? : Sql dba
How to use transactions efficiently : transact sql
what are the differences among rownum, rank and dense_rank? : Sql dba
what is the functionality of the function htmlentities? : Sql dba
Is sql injection illegal?