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 sql and also describe types of sql statements?
name 3 ways to get an accurate count of the number of records in a table? : Sql dba
What is information schema in sql?
What does partition by mean in sql?
What are views in sql?
How do I save the results of sql query in a file?
What is sql*loader?
What is a loop in sql?
What is %type in pl sql?
what is a field in a database ? : Sql dba
Under what condition it is possible to have a page level lock and row lock at the same time for a query? : Transact sql
What is procedure explain with program?
What is count * in sql?
How do I find duplicates in two columns?
how to see the create table statement of an existing table? : Sql dba