High severitydata
Oracle Database Error:
ORA-02291
What does this error mean?
An INSERT or UPDATE violated a FOREIGN KEY constraint because the referenced parent row does not exist in the parent table.
Common causes
- 1Child rows are loaded before parent rows (wrong pipeline execution order)
- 2Parent record was deleted after the child pipeline read the FK value
- 3Source data references a foreign key that does not exist in the target
- 4Pipeline loads to child table in parallel with parent table inserts, causing race conditions
How to fix it
- 1Step 1: Ensure parent tables are loaded before child tables — fix the pipeline execution order.
- 2Step 2: Identify the missing parent key from the error message and trace it to the source.
- 3Step 3: Add a pre-load validation: `SELECT child_fk FROM child_source WHERE child_fk NOT IN (SELECT pk FROM parent_target)`;`.
- 4Step 4: Temporarily disable the FK constraint for the load, then re-enable and validate: `ALTER TABLE child DISABLE CONSTRAINT fk_name;`.
- 5Step 5: For orphaned records, decide: insert a placeholder parent row, skip the child row, or fix the source data.
Example log output
ORA-02291: integrity constraint (SCHEMA.FK_ORDER_CUSTOMER) violated — parent key not found
SQL: INSERT INTO orders (id, customer_id) VALUES (101, 9999)