which will fire first ? Trigger or Constraint

Answers were Sorted based on User's Feedback



which will fire first ? Trigger or Constraint..

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

which will fire first ? Trigger or Constraint..

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

which will fire first ? Trigger or Constraint..

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

which will fire first ? Trigger or Constraint..

Answer / roopa

trigger fires first.

Is This Answer Correct ?    1 Yes 29 No

Post New Answer

More SQL PLSQL Interview Questions

i have a table t1 a math 20 b phy 30 cchemisty 10 a math 40 b phy 23 c che 21 a math15 bphy 33 c che 56 write a quire to find out the max markr of each subject

8 Answers  


What is Overloading of procedures ?

2 Answers  


What is sql analyzer?

0 Answers  


What is diff between bulk collect and forall

3 Answers   Metric Stream,


What is t-sql? : Transact sql

0 Answers  






What is difference between nchar and nvarchar?

0 Answers  


What is consistency?

0 Answers  


Mention what does the hierarchical profiler does?

0 Answers  


How we can create a table in pl/sql block. Insert records into it? Is it possible by some procedure or function? Please give example?

0 Answers  


how to delete duplicate rows from a specified table(only single table) how do you know which join is need to be used

11 Answers   UST,


What is group by in sql?

0 Answers  


Why trigger is used in sql?

0 Answers  


Categories