Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Integrity Constraints in Database Triggers
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