Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Integrity Constraints in Database Triggers

Integrity Constraints in Database Triggers

From: Sean McMurray <smcmurr_at_admin.dce.utah.edu>
Date: Thu, 29 Apr 1999 13:58:52 -0700
Message-ID: <3728C80C.1D728CF4@admin.dce.utah.edu>


I have an AFTER UPDATE trigger with the following logic:

IF nvl(:new.colname, '') != nvl(:old.colname, '') THEN

    select change_seq.NEXTVAL into m from dual;     insert into change_log(change_id, change_table, change_column, old_value, new_value, change_user, change_date)

        values(m, table_name, column_name, :old.colname, :new.colname, user, sysdate);

    insert into change_key(change_id, key, type, value)

        values(m, 'some_key', 'VARCHAR2', :new.keycolname); END IF; The change_key table has the following constraint

    CONSTRAINT fk_my_constraint FOREIGN KEY (change_id)

        REFERENCES change_log(change_id)

When this trigger fires, it gives me an integrity constraint error:

ORA-02291: integrity constraint (fk_my_constraint) violated - parent key not found

I specifically insert the parent record before the child record. Although I haven't performed a commit, the next insert should see the parent record in the rollback segment, right?

What am I missing here?

TIA Received on Thu Apr 29 1999 - 15:58:52 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US