Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

which will fire first ? Trigger or Constraint

Answer Posted / lakkireddy ashok

Always trigger will fire first

eg:create table T_CHK (a number check (A < 99));

INSERT INTO T_CHK VALUES(101);

ORA-02290: check constraint (APPS.SYS_C00207769) violated

if u create trigger
CREATE TRIGGER CHKT BEFORE INSERT ON T_CHK
FOR EACH ROW
BEGIN
IF :NEW.A >100 THEN
RAISE_APPLICATION_ERROR(-20011,'VALUES SHOULD BE < 100');
END IF;
END;

INSERT INTO T_CHK VALUES(101);

ORA-20011: VALUES SHOULD BE < 100
ORA-06512: at "APPS.CHKT", line 3
ORA-04088: error during execution of trigger 'APPS.CHKT'

if u don't create trigger then constraint will be first otherwise if u create trigger to the same table with same DML operations here trigger will fire first instead of constraint firing

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the two types of exceptions in pl/sql?

969


What is a sql*loader control file?

1165


what is myisam? : Sql dba

1001


Can we use loop in sql?

924


Why truncate is used in sql?

937


Is it possible for a table to have more than one foreign key?

980


What is the use of nvl function?

1128


explain access control lists. : Sql dba

949


How to find 3rd highest salary of an employee from the employee table in sql?

1037


How do you create a db file?

959


What is a left join?

890


How do I write a cron which will run a sql query and mail the results to agroup?

915


What are the uses of merge?

1120


What is AUTH_ID and AUTH_USER in pl/sql ?

2142


What are the types of subqueries?

1018