265 pts.
 Oracle Application Express Item
I have two tables with parent-child relationship. Is there a way to automatically populate the foreign key field of the child table with the exact data from the primary key of the parent table?

Software/Hardware used:
ASKED: April 8, 2008  1:04 PM
UPDATED: April 9, 2008  7:22 PM

Answer Wiki:
This depends upon the primary key of the child table. If a record already exists in the child table with the given foreign key value and the parent record is updated, then a "post update trigger" on the parent table can be written to update the foreign key value of the child table. All key values of the child table must be available to ensure you update the correct row. If a new record is inserted into the parent table with a new key value, then it would be necessary to have a "post insert trigger" on the parent table to create a new record in the child with the new value. But, this would not work properly unless all non-null and primary key column values were available to insert a new record into the child table. So, the short answer to your question is "yes, if you have the right information available."
Last Wiki Answer Submitted:  April 9, 2008  7:22 pm  by  Jcmdba   555 pts.
All Answer Wiki Contributors:  Jcmdba   555 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _