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
What is pl sql architecture?
What is an exception in pl/sql?
Can a trigger call a stored procedure?
What is sql profiling in oracle?
What is cursor and its types?
Why do we need unique key in a table?
Can a table contain multiple foreign key’s?
how to escape special characters in sql statements? : Sql dba
What is the purpose of cursors in pl/sql?
how to convert character strings to dates? : Sql dba
What does (+) mean in sql joins?
What is the difference between sql, mysql and sql server?
Explain what is a database?
Explain the insert into statements in sql?
Can you inner join the same table?