I want to bulk insert explicit data into two different tables linked by a foreign key using a same sequence-generated value in both tables.
I'm trying to use a INSERT ALL instruction together with a WITH clause made of successive UNION ALL statements to achieve that.
As long as the with clause returns no more than 256 rows, everything works fine. As soon as I add another UNION ALL entry, I'm getting the following error :
ORA-02291: integrity constraint violated (MY_SCHEMA.FK_TABLE_B_TO_TABLE_A) - parent key not found *Cause: A foreign key value has no matching primary key value. *Action: Delete the foreign key or add a matching primary key.
If I disable the foreign key constraint, then again everything works fine (even with more than 256 rows).
My instruction looks like this :
insert all
into MY_SCHEMA.TABLE_A (ID, COLUMN_1, COLUMN_2)
values (MY_SCHEMA.MY_SEQUENCE.nextval, COLUMN_1, COLUMN_2)
into MY_SCHEMA.TABLE_B (ID, COLUMN_3)
values (MY_SCHEMA.MY_SEQUENCE.nextval, COLUMN_3)
with input_data as (
select 11 COLUMN_1, 12 COLUMN_2, 13 COLUMN_3
UNION ALL
select 21 COLUMN_1, 22 COLUMN_2, 23 COLUMN_3
UNION ALL
...
UNION ALL
select 31 COLUMN_1, 32 COLUMN_2, 33 COLUMN_3
)
select * from input_data;
Is there some limitation on the amount of data that such an instruction can handle ? Or am I missing something else ?
I'm using Oracle 11g and SQLDeveloper.