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
Why is a primary key important?
Why triggers are used?
Which is better stored procedure or query?
Is join an inner join?
how to load data files into tables with 'mysqlimport'? : Sql dba
What are the different dcl commands in sql?
hi,i plan to put experience on PLSQL ,can anyone suggest me for any institutes in bangalore or how to prepare for interviews
What is the difference between the sql*loader and import utilities? : aql loader
How much does a sql dba make? : SQL DBA
How to take user input in pl sql?
What is the maximum number of columns in sql table?
Write a query to find the names of users that begin with "um" in sql?
What is row_number () in sql?
what is meant by nl2br()? : Sql dba
why does the selected column have to be in the group by clause or part of an aggregate function? : Sql dba