Maybe the following example will help (Oracle 18c). Ideas: {1} Synchronize the tables with MERGE. {2} Use a procedure for INSERTing into both tables.
Tables for testing
-- parent (always use DATE for dates!)
create table table2 ( id primary key, date_ )
as
select 1, to_date( '28/12/2019', 'DD/MM/YYYY' ) from dual union all
select 2, to_date( '30/12/2019', 'DD/MM/YYYY' ) from dual ;
-- child
create table table1 (
id number generated always as identity start with 5000 primary key
, table2id number references table2( id ) not null unique
) ;
-- the 2 tables contain the following data:
SQL> select * from table2 ;
ID DATE_
---------- ---------
1 28-DEC-19
2 30-DEC-19
SQL> select * from table1 ;
no rows selected
{1} MERGE
-- initial sync (P)arent <-> (C)hild
merge into table1 C
using table2 P on ( C.table2id = P.id )
when not matched then
insert ( C.table2id ) values ( P.id ) ;
-- 2 rows merged.
-- data
SQL> select * from table2 ;
ID DATE_
---------- ---------
1 28-DEC-19
2 30-DEC-19
SQL> select * from table1 ;
ID TABLE2ID
---------- ----------
5000 1
5001 2
{2} PROCEDURE
-- assumption: ("parent" table) table2 id generated by a sequence
-- sequence: use nextval and currval.
create sequence t2seq start with 2000 increment by 1 ;
create or replace procedure insert2 ( dt_ date )
is
begin
insert into table2 ( id, date_ ) values ( t2seq.nextval, dt_ ) ;
insert into table1 ( table2id ) values ( t2seq.currval ) ;
end ;
/
{3} Testing
begin
for i in 100 .. 105
loop
insert2( sysdate + i ) ; -- call the procedure, insert some dates
end loop;
commit ;
end ;
-- check:
SQL> select * from table1 ;
ID TABLE2ID
---------- ----------
5000 1
5001 2
5002 2000
5003 2001
5004 2002
5005 2003
5006 2004
5007 2005
8 rows selected.
SQL> select * from table2 ;
ID DATE_
---------- ---------
1 28-DEC-19
2 30-DEC-19
2000 07-APR-20
2001 08-APR-20
2002 09-APR-20
2003 10-APR-20
2004 11-APR-20
2005 12-APR-20
8 rows selected.
{4} Try to sync again -> 0 rows merged.
merge into table1 C using table2 P on ( C.table2id = P.id )
when not matched then
insert ( C.table2id ) values ( P.id ) ;
0 rows merged.
DBfiddle here.
NEXTVAL and CURRVAL documentation here.