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 |
What is a procedure in pl sql?
How to revise and re-run the last sql command?
how to get a list of columns in an existing table? : Sql dba
Can we create table inside stored procedure?
what are the drivers in mysql? : Sql dba
What are tuples in sql?
What is structural independence and why is it important?
What are triggers and its types?
What is a trigger in pl/sql?
what is myisam? : Sql dba
what is pragma ?
What is the difference between nvl function, ifnull function, and isnull function?
Oracle (3259)
SQL Server (4518)
MS Access (429)
MySQL (1402)
Postgre (483)
Sybase (267)
DB Architecture (141)
DB Administration (291)
DB Development (113)
SQL PLSQL (3330)
MongoDB (502)
IBM Informix (50)
Neo4j (82)
InfluxDB (0)
Apache CouchDB (44)
Firebird (5)
Database Management (1411)
Databases AllOther (288)