Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

What is the order of tirriger & constraints firing

Status
Not open for further replies.

kllick123

Technical User
Sep 24, 2002
22
IN
Hi,

If I had a table on which I had applied the column level contraints as primary key, foriegin key or check level constaints.

Also I had applied the triggers on it(Both statemenmt & row level).

Then what will fire first a constaint or a trigger ?
 
If you want to modify the column data on the fly, prior to being posted to the database, then you want to use a BEFORE trigger FOR EACH ROW. BEFORE triggers are fired before constraints. For example, they can be used to populate a PK column before the constraint has a chance to determine if the value is null or not.

If you try to use an AFTER trigger, then Oracle will tells you two things:
1. If you try to change the value of :new.column, Oracle will tell you "ORA-04084: cannot change NEW values for this trigger type."
2. If you try to change the value of :eek:ld.column, Oracle will tell you "ORA-04085: cannot change the value of an OLD reference variable."

I don't see the point in trying to do dynamic key setting on anything other than a row level trigger.

-Mark

9i OCP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top