Skip to content
Advertisement

INSERT ALL error ORA-02291 integrity constraint but PK is referenced

I’m creating a basic sales and inventory DB for a class.

I’ve successfully created the tables necessary with where I want my PK and FK’s to be.

The issue I’m running into now is when I try to perform a multiple insert into my employees table.

Here’s what has been created and inserted so far:

When I run the statement INSERT ALL INTO employees I get this error:

ORA-02291: integrity constraint (SQL_NCBYEZZVAYRPDIJSWAZMSKRHK.SYS_C0016383126) violated - parent key not found ORA-06512: at "SYS.DBMS_SQL", line 1721

Advertisement

Answer

The zip code values in your insert into the employees table don’t match the ones you created in the location table, so the error is valid and expected.

Either change the employees zip codes to match the locations you already have, or more likely – since you already use those for customers – add new locations for the zip codes you are trying to use:

db<>fiddle

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement