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

What is pls_integer in pl sql?

0 Answers  


Hello All, Could any well write a query for the following scenario. Account(table name) No Name Amount 1 ABCD 2000.00 2 DEFG -2000.00 3 GHIJ 3000.50 4 JKLM 4000.00 5 MNOP 6000.00 O/p Should be in this format No Name Credit Debit 1 ABCD 2000.00 0 2 DEFG 0 -2000.00 3 GHIJ 3000.50 4 JKLM 0 -4000.00 5 MNOP 6000.00 o could any one give appropriate query for this Thnks in Advance Suneel Reddy

6 Answers   Target,


if we give update table_name set column_name= default. what will happen?

4 Answers   iFlex,


Which data type is a composite type?

0 Answers  


Find out the 3rd highest salary?

51 Answers   BirlaSoft, DAC, Silvia Infotech, Sutra Infotech,






Can We write bulk collect statement in triggers?

1 Answers   Polaris,


What is a nested table in word?

0 Answers  


Can you select everything, but 1 or 2 fields, without writer's cramp?

0 Answers  


what is not null constraint? : Sql dba

0 Answers  


What is a mutating table

5 Answers   TCS, Tech Mahindra,


What does an inner join do?

0 Answers  


How does one use sql*loader to load images, sound clips and documents? : aql loader

0 Answers  


Categories