which will fire first ? Trigger or Constraint
Answers were Sorted based on User's Feedback
Answer / 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 |
Answer / dhananjay kumar singh
I am know trigger is fire firstly because trigger are
automatically fired and constraint are not fired
automatically.
Is This Answer Correct ? | 0 Yes | 2 No |
Answer / dhanashree
Trigger will fire first because the trigger fires at the
table level and the constraint fires at column level
Is This Answer Correct ? | 3 Yes | 7 No |
Why do we use function in pl sql?
what is the functionality of the function htmlentities? : Sql dba
What is compound trigger?
if we give update table_name set column_name= default. what will happen?
How to trace the errors in pl/sql block code?
explain the advantages and disadvantages of stored procedure? : Sql dba
How do I view a sql trace file?
What is an emotional trigger?
i hv 30 rows with date.ex:1month hav 4 weeks i want 1st day of the every week.write the qry for that.example jan has 4 weeks i need 1st dd for evry wk
what are sequences
What are the different type of joins in sql?
What is nosql db?