Skip to Main Content
  • Questions
  • IGNORE_ROW_ON_DUPKEY_INDEX like hint for Foreign Key Constraint Violation.

Breadcrumb

Question and Answer

Connor McDonald

Thanks for the question, Sunil Kumar.

Asked: April 05, 2017 - 1:55 am UTC

Last updated: April 07, 2017 - 2:12 am UTC

Version: 12c

Viewed 1000+ times

You Asked

Hi,

Like we have IGNORE_ROW_ON_DUPKEY_INDEX hint which will say to ignore any duplicates that are there in my select query, do we have any hint to say ignore records which violated foreign key constraints and load them?

For example: if I have 10 records from my select query, out of which record 4 and 9 will result into foreign key violation. Now if I say,

Insert into table
select * from <table1>; it will fail at the 4th record saying foreign key constraint violated and none of the records will be inserted. One way to get out of this is

Insert into table
select * from <table1> where exists (query......)

but this has to query against the other table in scenarios when we feel, constraint violation records can be ignored and rest of the valid records can be loaded this hint will be helpful.

and Connor said...

You could consider using DML error logging.

Here's a video explaining its use



Rating

  (1 rating)

Is this answer out of date? If it is, please let us know via a Comment

Comments

Great option

Sunil Kumar Noothi, April 05, 2017 - 4:00 am UTC

Hi Connor,

yeah I almost missed that option which I used before :( yes I can use this where all the error messages can be written to this error table. But just wondering why Oracle Introduced a hint for primary key only and not for foreign key?
Connor McDonald
April 07, 2017 - 2:12 am UTC

That hint came into existencen predominantly for edition based redefinition. So my guess would be EBR does not need a similar facility for foreign keys